home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / prog / fdate80a.arj / FDATE.DOC < prev    next >
Text File  |  1993-07-20  |  99KB  |  2,582 lines

  1. FDATE                     Version 8.0a               July 15, 1993
  2. ======================================================================
  3. AUTHOR:     Stephen Ferg             
  4.             5113 N. 8th Road
  5.             Arlington, VA 22205-1201
  6.             USA
  7.                          telephone (voice, not FAX): (703) 525-2241
  8.                          CompuServe ID             : 73377,1157
  9. =======================================================================
  10.  
  11.  
  12.  
  13.                              Table of Contents
  14.  
  15. Page numbers in the WordPerfect version of FDATE.DOC (which is not
  16. distributed with FDATE) are lost in the conversion to ASCII format. 
  17. Nevertheless, these page numbers give you a rough idea of the relative
  18. locations of the different sections.
  19.  
  20.   WHAT IS FDATE?. . . . . . . . . . . . . . . . . . . . . . . . . . . .   3
  21.      OTHER UTILITIES NAMED "FDATE". . . . . . . . . . . . . . . . . . .   3
  22.      OVERVIEW OF PARAMETERS . . . . . . . . . . . . . . . . . . . . . .   4
  23.      OVERVIEW OF FUNCTIONS. . . . . . . . . . . . . . . . . . . . . . .   6
  24.   FUNCTIONS: DETAILED DESCRIPTIONS. . . . . . . . . . . . . . . . . . .   8
  25.      DATE FORMATTING FUNCTIONS. . . . . . . . . . . . . . . . . . . . .   8
  26.      DATE ARITHMETIC FUNCTIONS. . . . . . . . . . . . . . . . . . . . .   9
  27.      MONTH DATE ARITHMETIC FUNCTIONS. . . . . . . . . . . . . . . . . .  10
  28.      WEEKDAY DATE ARITHMETIC FUNCTIONS. . . . . . . . . . . . . . . . .  11
  29.      DATE/TIME COMPARISON FUNCTIONS . . . . . . . . . . . . . . . . . .  12
  30.      NUMERIC ARITHMETIC FUNCTIONS . . . . . . . . . . . . . . . . . . .  13
  31.      DATE VALIDATION FUNCTION . . . . . . . . . . . . . . . . . . . . .  15
  32.      ECHO FUNCTION. . . . . . . . . . . . . . . . . . . . . . . . . . .  16
  33.   DATE FORMATS. . . . . . . . . . . . . . . . . . . . . . . . . . . . .  17
  34.      SYMBOL CONVENTIONS . . . . . . . . . . . . . . . . . . . . . . . .  17
  35.      PSEUDODATES. . . . . . . . . . . . . . . . . . . . . . . . . . . .  18
  36.   INPUT DATE FORMATS. . . . . . . . . . . . . . . . . . . . . . . . . .  19
  37.      CALENDAR DATE INPUT FORMATS. . . . . . . . . . . . . . . . . . . .  19
  38.      BUSINESS JULIAN DATE INPUT FORMATS . . . . . . . . . . . . . . . .  20
  39.      GETTING DATE/TIME A FILE WAS CREATED . . . . . . . . . . . . . . .  21
  40.   OUTPUT DATE FORMATS . . . . . . . . . . . . . . . . . . . . . . . . .  22
  41.      DAY-OF-WEEK AND MONTH OUTPUT FORMATS . . . . . . . . . . . . . . .  23
  42.      MISCELLANEOUS OUTPUT FORMATS . . . . . . . . . . . . . . . . . . .  23
  43.      LEAP-YEAR FLAG OUTPUT FORMAT . . . . . . . . . . . . . . . . . . .  24
  44.      TIME OUTPUT FORMATS. . . . . . . . . . . . . . . . . . . . . . . .  24
  45.      BUSINESS JULIAN DATE OUTPUT FORMATS. . . . . . . . . . . . . . . .  25
  46.      ABSOLUTE DATE/TIME OUTPUT FORMATS. . . . . . . . . . . . . . . . .  26
  47.      /T: TIME OVERRIDE PARAMETER. . . . . . . . . . . . . . . . . . . .  27
  48.   HOW TO PUT FDATE OUTPUT INTO AN ENVIRONMENT VARIABLE. . . . . . . . .  28
  49.      CALL A BATCH FILE. . . . . . . . . . . . . . . . . . . . . . . . .  28
  50.      USE AN ENVIRONMENT-MANIPULATION UTILITY. . . . . . . . . . . . . .  28
  51.      FDATE'S /V PARAMETER . . . . . . . . . . . . . . . . . . . . . . .  29
  52.      /V WHEN USING 4DOS, NDOS, AND UMB. . . . . . . . . . . . . . . . .  30
  53.   FDATE'S ERROR HANDLING. . . . . . . . . . . . . . . . . . . . . . . .  31
  54.   EXAMPLES OF HOW TO USE FDATE. . . . . . . . . . . . . . . . . . . . .  32
  55.      :01 Display Fdate output on screen . . . . . . . . . . . . . . . .  32
  56.      :02 Redirect FDATE output to a file. . . . . . . . . . . . . . . .  32
  57.      :03 Put FDATE output in an environment variable using a batch file  32
  58.      :04 Put FDATE output in an environment variable using /V parm. . .  32
  59.      :05 Put FDATE output in an environment variable using STRINGS. . .  32
  60.      :06 Put FDATE output in an environment variable using GET. . . . .  32
  61.      :07 Change a date from one format into another . . . . . . . . . .  32
  62.      :11 Find the difference in days between two dates. . . . . . . . .  33
  63.      :12 Find the elapsed days/hours/minutes between two date/times . .  33
  64.      :13 Time the execution of a piece of software. . . . . . . . . . .  35
  65.      :15 Find calendar date corresponding to a "business Julian" date .  37
  66.      :16 Set your PC's date to a business julian date . . . . . . . . .  38
  67.      :18 Determine if parm %1 contains a valid date . . . . . . . . . .  40
  68.      :19 "Roll your own" date format  . . . . . . . . . . . . . . . . .  41
  69.      :20 Find the 4th Thursday in November (Thanksgiving) . . . . . . .  41
  70.      :22 On a date, show what anniversary it is for some event. . . . .  41
  71.      :23 Show a list of holidays in a given year. . . . . . . . . . . .  41
  72.      :24 Show a list of Federal holidays in a given year. . . . . . . .  41
  73.      :25 Determine if a year is valid, and evenly divisible by 4. . . .  42
  74.      :30 Compare a file's date to today's date. . . . . . . . . . . . .  42
  75.      :32 Display a list of all files that were created/updated today. .  43
  76.      :34 Loop through an array of environment variables . . . . . . . .  44
  77.      :44 Do something on the last day (or last Friday) of the month . .  45
  78.      :45 Get information about the month prior to the current month . .  46
  79.      :51 Represent a date in a short (4-byte) format (technique #1) . .  47
  80.      :52 Represent a date in a short (4-byte) format (technique #2) . .  48
  81.      :53 SetXX.BAT (used in the previous example) . . . . . . . . . . .  50
  82.      :54 Customize Fdate for a language of your choice. . . . . . . . .  52
  83.      :55 Fergian.BAT (used in the previous example) . . . . . . . . . .  53
  84.      :61 DO-ONCE: Run apps when booting for the first time of the day .  55
  85.      :62a Run specific software, depending on the day of the week . . .  56
  86.      :62b Run specific software, depending on the day of the week . . .  57
  87.      :63 Run a program at a specified time later in the day . . . . . .  57
  88.      :67 Change a file's name to a name that contains today's date. . .  58
  89.      :68 Change a file's name to a name containing an absolute minute .  58
  90.   HOW FDATE THINKS ABOUT DATES. . . . . . . . . . . . . . . . . . . . .  59
  91.      FDATE'S BUSINESS VIEW OF THE CALENDAR. . . . . . . . . . . . . . .  59
  92.      FDATE'S BASE DATE. . . . . . . . . . . . . . . . . . . . . . . . .  59
  93.      FDATE'S LEAP YEAR ALGORITHM. . . . . . . . . . . . . . . . . . . .  60
  94.      FDATE'S CENTURY-ASSUMPTION ALGORITHM . . . . . . . . . . . . . . .  61
  95.      FDATE'S IMPLEMENTATION LIMITS. . . . . . . . . . . . . . . . . . .  61
  96.   DISTRIBUTION ISSUES . . . . . . . . . . . . . . . . . . . . . . . . .  62
  97.      USE, REGISTRATION, AND DISTRIBUTION OF FDATE . . . . . . . . . . .  62
  98.      TECHNICAL SUPPORT FOR FDATE. . . . . . . . . . . . . . . . . . . .  63
  99.      WHERE TO FIND THE MOST CURRENT VERSION OF FDATE. . . . . . . . . .  63
  100.      UPLOADING FDATE TO ELECTRONIC BULLETIN BOARDS. . . . . . . . . . .  63
  101.      DEMONSTRATION BATCH FILES. . . . . . . . . . . . . . . . . . . . .  63
  102.      CONTENTS OF THE FDATE.ZIP DISTRIBUTION FILE. . . . . . . . . . . .  63
  103.      FDATE REVISION HISTORY . . . . . . . . . . . . . . . . . . . . . .  64
  104.  
  105. WHAT IS FDATE?
  106. ==============
  107.  
  108. Fdate is a utility for doing date formatting and date arithmetic in DOS
  109. batch files.  There are a number of different ways to put FDATE's output
  110. into environment variables.  Once this has been done, the environment
  111. variables can be used and manipulated in many ways in the batch file.
  112.  
  113. FDATE is freeware, or what is technically known as "zero-cost shareware". 
  114. There is no requirement to register FDATE in any way.  For more details,
  115. see the DISTRIBUTION ISSUES section.
  116.  
  117. Here are some of the things you can do with FDATE.
  118.  
  119.     retrieve today's date in a variety of formats
  120.       place today's date into a file name
  121.  
  122.     reformat dates 
  123.        Output formats include common American and European formats, or you
  124.        can "roll your own" by manipulating environment variables.  Month
  125.        and weekday names can be produced in several languages (English,
  126.        French, German, Spanish).
  127.  
  128.     calculate when certain holidays occur in a given year
  129.  
  130.     do date arithmetic
  131.       determine the date N days before/after a given date
  132.       compare two dates to determine which is earlier
  133.       compare two dates to determine how many days apart they are
  134.  
  135.     determine if a year is a leap year
  136.     determine whether a year is evenly divisible by some number
  137.  
  138.     determine what day of the week a date falls on
  139.       run certain software only on certain days of the week
  140.  
  141.     retrieve the date/time from the date/timestamp of a file
  142.     do simple integer arithmetic (add, subtract, modulus)
  143.     calculate the time a piece of software takes to run
  144.     convert a calendar date to/from a "business julian" date
  145.  
  146.  
  147.  
  148. OTHER UTILITIES NAMED "FDATE"
  149. =============================
  150. I recently learned that there is another shareware utility named FDATE in
  151. circulation.  It is an implementation of the UNIX "touch" utility, and is
  152. used to change the date/time stamp of a file.  
  153.  
  154. Both FDATEs have been in circulation for too long to make it practical to
  155. change the name of either one.  All that can be done is to warn you of a
  156. potentially confusing situation.
  157.  
  158. OVERVIEW OF PARAMETERS
  159. ======================
  160.  
  161. FDATE accepts the following parameters:
  162.  
  163.        /F /A /B /I /O /P /S /N /D /L /V /T
  164.  
  165.  
  166. The only parameter that FDATE requires is the function parameter: /F.
  167.  
  168. If the /F parameter is not present, FDATE displays a help screen.  
  169.      If you get FDATE's help screen when you don't expect it, you probably
  170.      forgot to specify the /F parameter or mistyped it.
  171.  
  172. Parameters can be in any order and upper or lower case.
  173.      Note that although function and format parms are not case sensitive,
  174.      they are "text sensitive".  If any characters are missing, added, or
  175.      mistyped, the parameter will be rejected.
  176.  
  177. Parameters -- other than /F -- that are required depend on the function
  178. requested with the /F parameter.  Unnecessary parameters are simply
  179. ignored.
  180.  
  181.  
  182.  
  183. The next page contains a brief description of what each of the parameters
  184. means.
  185.  
  186. /F   requests a particular FDATE function.  This is Fdate's most important
  187.      parameter.  See the OVERVIEW OF FUNCTIONS section, and the detailed
  188.      description of each Fdate function.
  189.  
  190. /N   number of days (always a number)
  191.  
  192. /D   day-of-week number (used only with W function)
  193.  
  194. /A   
  195. /B   For date functions, these two parameters are used to specify dates. 
  196.      For the ordinary arithmetic functions, these parameters are used to
  197.      specify numbers.  For date functions, if either of these parameters is
  198.      omitted, it defaults to today's date.
  199.  
  200. /T   For date functions, /T overrides the time portion of the date on the
  201.      /A parm. (Note that it does NOT override the time portion of the date
  202.      on the /B parm.)  
  203.  
  204. /I   specifies format of input date(s)
  205.      If the /I parameter is omitted, /Imm-dd-ccyy is assumed.
  206.  
  207. /O   specifies format of output date
  208.      If the /O parameter is omitted, /Od1 is assumed.
  209.  
  210. /L  specifies language of output.
  211.      /Lus   US (American) English-language output
  212.      /Lfr   French-language output
  213.      /Lgr   German-language output
  214.      /Lsp   Spanish-language output
  215.      If the /L parameter is omitted, /Lus [American English] is assumed.
  216.  
  217. /V   specifies that output is to be placed in an environment variable
  218.      rather than written to standard output.
  219.      If /V is specified but not followed by the name of an environment
  220.      variable, then /Vfdate is assumed, and output is placed in the FDATE
  221.      environment variable.
  222.  
  223. /P  specifies a prefix string for the output
  224. /S  specifies a suffix string for the output
  225.     These optional parameters may always be specified or omitted.
  226.     They must be enclosed in single quotes, double quotes, or
  227.                   square brackets
  228.  
  229.     Note that "whitespace" will be removed from these strings,
  230.     so formatting of /P and /S strings cannot be controlled using
  231.     spaces.  To format strings, use periods or ASCII 255 (hex'ff')
  232.     as filler.
  233.  
  234.     EXAMPLES
  235.     FDATE /Ff                /P"Today is "
  236.     FDATE /Fdif /B12-25-TTTT /P"It is " /S" days until Christmas"
  237.  
  238. OVERVIEW OF FUNCTIONS
  239. =====================
  240.  
  241. Fdate's most important parameter, and the only one for which there is no
  242. default value, is the function parameter, /F.  Here is a brief summary of
  243. the functions that may be specified on the /F parm, for example: /Fadd. 
  244. Detailed descriptions of each of the functions can be found on the next few
  245. pages.
  246.  
  247. f         Format the date in the /A parm into the format specified in the
  248.           /O parm
  249.  
  250. add       Add the number of days in the /N parm to the date in the /A parm
  251.  
  252. sub       Subtract the number of days in the /N parm from the date in the
  253.           /A parm
  254.  
  255. m         Monthly arithmetic.  Add the number of months in the /N parm to
  256.           the date in the /A parm.  /N may be a negative number.
  257.  
  258. dif       Return the number of days between dates in the /A and /B parms
  259.  
  260. w         Do date arithmetic in terms of weeks rather than days.  Using the
  261.           date in the /A parm, a number specified in the /N parm, and a
  262.           day-of-the-week number specified in the /D parm, return the date
  263.           of the /Nth /Day-of-the-week before (or after) /Adate.  
  264.  
  265. e         Echo the strings on the /P and /S parameters.
  266.  
  267.  
  268.  
  269.           DATE/TIME COMPARISON FUNCTIONS
  270.  
  271. comp      Compare the dates in the /A and /B parms. Return LT, EQ, or GT.
  272.  
  273. tcomp     Compare the times specified on the /A and /B parms.
  274.  
  275.  
  276.  
  277.           ORDINARY (AS OPPOSED TO DATE) ARITHMETIC FUNCTIONS
  278.  
  279.           Functions whose names begin with "#" do ordinary arithmetic, i.e.
  280.           arithmetic on numbers rather than dates.
  281.  
  282. #add      Add the integers specified on the /A and /B parms.  To do
  283.           subtraction, add a negative number to a positive number.
  284.  
  285. #dif      returns the difference between the integers specified on the /A
  286.           and /B parms. 
  287.  
  288. #comp     Compare the integers specified on the /A and /B parms.  Return
  289.           LT, EQ, or GT.
  290.  
  291. #mod      Modulus.  Divide the integer on the /A parm by the integer on the
  292.           /B parm, and return the remainder.  
  293.  
  294. #mult     Multiply the integer on the /A parm by the integer on the /B
  295.           parm, and return the result.
  296.  
  297. #div      Divide the integer on the /A parm by the integer on the /B parm,
  298.           and return the result as a decimal number with two decimal
  299.           places.
  300.  
  301. #idiv     Integer division. Divide the integer on the /A parm by the
  302.           integer on the /B parm, and return the result as an integer.
  303.  
  304. FUNCTIONS: DETAILED DESCRIPTIONS
  305. ================================
  306.  
  307.  
  308. DATE FORMATTING FUNCTIONS
  309. =========================
  310.  
  311. FUNCTION  FDATE /Ffunc /Adate /Iformat /Oformat
  312. --------  -------------------------------------------
  313. format    this is a synonym for function "f"
  314.  
  315. f         returns /Adate in format specified by /Oformat
  316.           Since /Aformat and /Oformat can be different, the FORMAT
  317.           function is used to change a date from one format to another.
  318.           Because of the wide variety of output formats, the FORMAT
  319.           function can also be used to determine the day of week of the
  320.           date, whether the date is in a normal or leap year, etc.
  321.  
  322. EXAMPLES
  323.           FDATE /Ff /A19920101 /Iccyymmdd /O"mn zd, ccyy"
  324.           FDATE /Ff       /Atoday         /Od1
  325.           FDATE /Fformat  /Atoday         /Od1
  326.           FDATE /Ff /If /Afdate.exe /P"FDATE.EXE last updated: " /Ofull
  327.  
  328. DATE ARITHMETIC FUNCTIONS
  329. =========================
  330.  
  331. Internally, numbers in Fdate are stored in Turbo Pascal's LONGINT datatype,
  332. which means that Fdate can accept numbers up to 9 digits long.
  333.  
  334. FUNCTION  FDATE /Ffunc /Nnumdays /Adate /Iformat /Oformat
  335. --------  -------------------------------------------
  336. add       Adds      /Ndays to   /Adate, produces date in /Oformat format
  337. sub       Subtracts /Ndays from /Adate, produces date in /Oformat format
  338.  
  339.           EXAMPLES
  340.           FDATE /Fadd /N90 /A01-01-1992 /Imm-dd-ccyy /Od1
  341.           FDATE /Fsub /N90 /A01-01-1992 /Imm-dd-ccyy /Od1
  342.           FDATE /Fadd /N90 /Atoday                   /Od1
  343.  
  344. dif       Returns number of days between /Adate and /Bdate
  345.           Order of the two dates is not significant.
  346.  
  347.           NOTE THAT:
  348.           For DIF, both dates must be in the SAME format, the input format
  349.           specified in /Iformat.  If the two dates are not in the same
  350.           format, you must first reformat one of the dates using the /Ff
  351.           function, then use DIF to get their difference.
  352.  
  353.           EXAMPLES
  354.           FDATE /Fdif /A01-01-1992 /B11-11-1992  /Imm-dd-ccyy
  355.           FDATE /Fdif /A11-11-1992 /B01-01-1992  /Imm-dd-ccyy
  356.           FDATE /Fdif /Atoday      /B01-01-1992  /Imm-dd-ccyy
  357.  
  358. MONTH DATE ARITHMETIC FUNCTIONS
  359. ===============================
  360.  
  361. FUNCTION  FDATE /Ffunc /Nnumdays /Adate /Iformat /Oformat
  362. --------  -------------------------------------------
  363. m         Adds /N months to /Adate, produces date in /Oformat format.  This
  364.           function can also be used to do monthly subtraction by making the
  365.           number in the /N parameter a negative number.
  366.  
  367.           EXAMPLES
  368.  
  369.           FDATE /Fm /N1  /A03-15-1992 /Imm-dd-ccyy /Omm-dd-ccyy
  370.                   produces:   04-15-1992
  371.  
  372.           FDATE /Fm /N-1 /A03-30-1991 /Imm-dd-ccyy /Omm-dd-ccyy
  373.                   produces:   02-28-1991
  374.  
  375.           FDATE /Fm /N-1 /A03-30-1992 /Imm-dd-ccyy /Omm-dd-ccyy
  376.                   produces:   02-29-1992
  377.  
  378.  
  379.           Note that a too-simple algorithm for month arithmetic can produce
  380.           non-existent dates.  Subtracting a month from March 30, 1991 (as
  381.           in the second example) could produce a result of February 30,
  382.           1991, a date which cannot exist.  
  383.  
  384.           Fdate's month arithmetic is more sophisticated than that.  If
  385.           Fdate finds that a simple month-arithmetic operation produces an
  386.           invalid date, it subtracts the minimum number of days required to
  387.           produce a valid date.  
  388.  
  389.           Thus, in the second example, it produces February 28, 1991, the
  390.           last date in February, 1991.  In the third example, it produces
  391.           February 29, 1992 because 1992 is a leap year.  
  392.  
  393.  
  394. Note that telling Fdate to add 12 months to February 29, 1992 produces a
  395. result of February 28, 1993, since 1993 is not a leap year.  See Peter G.
  396. Neumann's INSIDE RISKS column in COMMUNICATIONS OF THE ACM, June 1992 (Vol.
  397. 35, No. 6), entitled "Leap-Year Problems":
  398.  
  399.   Prime Computer's MAGSAV failed at midnight [on Feb 29, 1992]...  G. M.
  400.   Lack noted that MAGSAV probably failed on leap-day because it tried to
  401.   increment the year by one to set a tape label expiration date, and the
  402.   resulting nonexistent date of Feb 29, 1993 threw it for a loop.
  403.  
  404. WEEKDAY DATE ARITHMETIC FUNCTIONS
  405. =================================
  406.  
  407. FUNCTION  FDATE /Ffunc /Adate /Iformat /Oformat /Ddow#  /Ndow-count
  408. --------  -----------------------------------------------------------
  409. w         This function provides a way of doing date arithmetic in terms of
  410.           weeks rather than days.
  411.  
  412.           This function accepts a date specification in parm /A and
  413.           returns the date of the /Nth /Day-of-the-week
  414.           before or after /Adate.  For example:
  415.  
  416.           If    /A specifies November 14, 1992
  417.                 /D specifies the number for Thursday (i.e., 5)
  418.                 /N specifies a week count of 3
  419.           then /Fw returns the date of the third Thursday after
  420.           November 14, 1992. (See full example, below)
  421.  
  422.           Note that /N may be negative.  If, in the above example, /N
  423.           is specified as -3, then Fdate returns the date of the third
  424.           Thursday BEFORE November 14, 1992.
  425.  
  426.           If the date specified on the /A parms falls on the same day
  427.           of the week as was specified on the /D parm, then that will
  428.           be considered to be the first date meeting that day-of-week
  429.           criterion.  That is, if November 14, 1992 fell on a
  430.           Thursday, and if /N was 1 or -1, then the output date would
  431.           be the same as the input date, i.e.  November 14, 1992.
  432.  
  433.           The acceptable values for /N (number of weeks) is in
  434.           the range of 99..-99.  A value of zero (i.e. /N0) is invalid.
  435.  
  436. EXAMPLES
  437.      find date of Thanksgiving (4th Thursday in November) in 1992
  438.          FDATE /Fw /A11-01-1992 /Imm-dd-ccyy /D5 /N4 /Od1
  439.      returns: Thursday November 26, 1992
  440.  
  441.      find the beginning of the work-week (Monday, 2nd day of week)
  442.      AFTER Thanksgiving, 1992
  443.          FDATE /Fw /A11-26-1992 /Imm-dd-ccyy /D2 /N1 /Od1
  444.  
  445.      find the beginning of the work-week (Monday, 2nd day of week)
  446.      BEFORE Thanksgiving, 1992
  447.          FDATE /Fw /A11-26-1992 /Imm-dd-ccyy /D2 /N-1 /Od1
  448.  
  449.      get last Friday's date
  450.         rem Find next Friday's date (or today's date, if today is Friday).
  451.         rem Then find the Friday that precedes that Friday.
  452.         FDATE /Fw /At     /Omm-dd-ccyy  /D6 /N+1  /VGET
  453.         FDATE /Fw /A%GET% /Imm-dd-ccyy  /D6 /N-2  /VGET
  454.         Echo Last Friday was %GET%
  455.  
  456. DATE/TIME COMPARISON FUNCTIONS
  457. ==============================
  458.  
  459. FUNCTION  FDATE /Ffunc /Adate /Bdate /Iformat
  460. --------  -------------------------------------------
  461. comp      compares the dates (time granularity = 1 day)
  462.           specified on the /A and /B parms.
  463.           returns         when
  464.             LT            /A  is less than    (earlier than) /B
  465.             EQ            /A  is equal to     (same as)      /B
  466.             GT            /A  is greater than (later than)   /B
  467.  
  468. tcomp     compares the times (time granularity = 1 second)
  469.           specified on the /A and /B parms.
  470.           This is useful when input format /If (file) is specified.
  471.           It can be used to compare the timestamps of two files and
  472.           determine which is older.
  473.               EXAMPLE: Fdate /Ftcomp /If /Amyfile.1 /Byourfile.1
  474.  
  475.           returns         when
  476.             LT            /A  is less than    (earlier than) /B
  477.             EQ            /A  is equal to     (same as)      /B
  478.             GT            /A  is greater than (later than)   /B
  479.  
  480. NUMERIC ARITHMETIC FUNCTIONS
  481. ============================
  482.  
  483. Note that all of Fdate's arithmetic functions operate on integers.  A
  484. decimal number on an input parameter will be rejected, and an error message
  485. will be displayed.
  486.  
  487. FUNCTION  FDATE /Ffunc /Anum  /Bnum
  488. --------  -------------------------------------------
  489.  
  490. #add      returns the sum of the integers specified
  491.           on the /A and /B parms.  Can be used to calculate the
  492.           "absolute" minute(second, date) in the future from a given
  493.           "absolute" minute(second, date).   Also useful in generating
  494.           sequences of numbers and looping (see EXAMPLES).
  495.  
  496. #sub      (not supported)
  497.           Fdate does not provide a numeric subtraction operation as such. 
  498.           To do subtraction, add two numbers, one of which is a negative
  499.           number.  For example, to subtract 3 from 2:
  500.               FDATE /F#add /A2 /B-3          [ returns: -1 ]
  501.  
  502. #dif      returns the difference between the integers specified on the /A
  503.           and /B parms.  #dif is the same as subtraction in which the
  504.           smaller number is subtracted from the larger number; it will
  505.           never return a negative number.  It can be used to calculate the
  506.           number of minutes(seconds, days) between two
  507.           "Absolute"  minutes(seconds, dates).
  508.  
  509. #comp     compares the integers specified on the /A and /B parms.
  510.           returns         when
  511.             LT            /A  is less    than /B
  512.             EQ            /A  is equal   to   /B
  513.             GT            /A  is greater than /B
  514.  
  515. #mod      divides the integer on the /A parm by the integer on the /B parm,
  516.           and returns the remainder.  
  517.  
  518.           This is useful for determining whether a number is evenly
  519.           divisible by some other number.  If the remainder is 0, then /A
  520.           is evenly divisible by /B.  If a year is evenly divisible by 4,
  521.           for example, then it is an American election year.  If it is
  522.           evenly divisible by 100, then it is a century year, etc.
  523.  
  524.  
  525. #mult     multiplies the integer on the /A parm by the integer on the /B
  526.           parm, and returns the result.
  527.  
  528. #div      (division) divides the integer on the /A parm by the integer on
  529.           the /B parm, and returns the result as a decimal number, with two
  530.           digits to the right of the decimal.
  531.  
  532.           This is useful for dividing a number (representing the number of
  533.           minutes in some period) by 60 to get the length of the period
  534.           expressed in terms of hours, or by 1440 to get the length of the
  535.           period expressed in terms of days.  Or you could divide a number
  536.           of days by 7 to get the number of weeks, etc.
  537.  
  538.  
  539. #idiv     (integer division) divides the integer on the /A parm by the
  540.           integer on the /B parm, and returns the result as an integer.
  541.  
  542.           This is useful, especially in conjunction with the #mod function,
  543.           for converting a number of minutes into a number of hours and
  544.           minutes, or days and hours and minutes.  See the EXAMPLES
  545.           section, below.
  546.  
  547. DATE VALIDATION FUNCTION
  548. ========================
  549.  
  550. v    If the date specified on the /A parm is valid, produces "" (the null
  551.      string).  Otherwise, produces "ERROR" and a non-zero errorlevel by
  552.      triggering Fdate's error-handling function.  (See the section on
  553.      FDATE'S ERROR HANDLING, later in this documentation.)
  554.  
  555.      When processing an input date, Fdate does not reject all invalid
  556.      dates: specifically, it is very forgiving about the number in the day-
  557.      of-the-month part of input dates.  It will accept, for example,
  558.      19931144 (November 44, 1993 in CCYYMMDD format) and process it quite
  559.      happily (as December 14, 1993).  This is not a bug, it is a feature. 
  560.      This feature provides one way (admittedly a crude one) of doing date
  561.      arithmetic.  The date part (JJJ) of a Business Julian input date can
  562.      be used in the same way.  
  563.  
  564.      This feature can be a drawback, however, if you want to be sure that
  565.      some date (say a date that a user entered as an input parameter) is
  566.      valid.  The /Fv function provides a way of completely checking a date
  567.      for validity.  It will, for example, reject November 44, 1993 as
  568.      invalid. 
  569.  
  570.  
  571.  
  572. ECHO FUNCTION
  573. =============
  574.  
  575. e         Produces only the strings specified using the /P and /S
  576.           parameters.
  577.  
  578. You can use /Fe for situations in which you want Fdate to produce output
  579. that doesn't include any sort of date.  In these cases, Fdate functions
  580. just like the DOS "echo" command.  
  581.  
  582. The real use for /Fe is in conjunction with /V, where it can be used to
  583. manipulate the environment in ways that DOS's SET command cannot:
  584.  
  585.   (1)  to give a value to an environment variable that it would not accept
  586.        from the SET command (e.g. a value that contained "=").
  587.  
  588.   (2)  to redirect or pipe a character-string that contains a redirection
  589.        symbol ">" or pipe symbol "|".
  590.  
  591. This feature is for real batch-file power users.
  592.  
  593.  
  594.  
  595. EXAMPLE BATCH FILE
  596. ------------------
  597.   @ECHO OFF
  598.   set pct=%%%
  599.   Fdate /Fe /P"=Sam=" /vName
  600.   Fdate /Fe /P"echo ECHO Hi, %pct%Name%pct%!>junk2.bat">junk1.bat
  601.      :  RESULT: TEXT OF JUNK1.BAT IS
  602.      :          echo ECHO Hi, %Name%!>junk2.bat
  603.   call junk1.bat
  604.      :  RESULT: TEXT OF JUNK2.BAT IS
  605.      :          ECHO Hi, =Sam=!
  606.   call junk2.bat
  607.      :  RESULT: TEXT DISPLAYED ON SCREEN IS
  608.      :          Hi, =Sam=!
  609.   :endit
  610.  
  611.  
  612. DATE FORMATS
  613. ============
  614.  
  615. SYMBOL CONVENTIONS
  616. ==================
  617.  
  618. The following symbols are used in specifying date formats:
  619.  
  620. SYMBOL  EXAMPLE   MEANING
  621. ------  -------   -------------------------------------
  622. cc        19      century
  623. yy        93      year
  624. mm        02      month
  625. zm         2      month without leading zero
  626. dd        08      day
  627. zd         8      day   without leading zero
  628. mn       February month name
  629. mn3      Feb      month name, first 3 characters only
  630. dow      Tuesday  day of week
  631. dow3     Tue      day of week, first 3 characters only
  632. dow#      3       day of week as a number (Sunday=1, Monday = 2, etc.)
  633. today             is a "pseudodate" representing the current date
  634. t                 is an alias for the "today" pseudodate
  635. hh:mm    09:05    hours and minutes
  636. hhmm     0905     hours and minutes
  637. ss        13      seconds
  638.  
  639.  
  640.  
  641. PSEUDODATES
  642. ===========
  643.  
  644. t (or today)
  645.           can be used with either /A or /B, e.g. /Atoday or /At.
  646.           This is the default for both /A and /B.  That is, if /A is not
  647.           specified, /At is assumed, and the same for /B.
  648.  
  649.           NOTE THAT
  650.           "Today" as a date specification operates independently of any
  651.           input format.  You need to specify an input format (either
  652.           explicitly via the /I parameter, or implicitly by accepting the
  653.           default value of /I) only for input dates that are supplied to
  654.           Fdate in some other way than via the "today" pseudodate: as a
  655.           date literal, a filename, etc.
  656.  
  657. EXAMPLES:
  658.           rem Get the date that is 90 days from today
  659.           FDATE /Fadd /N90 /Atoday /Omm-dd-ccyy
  660.           FDATE /Fadd /N90 /At     /Omm-dd-ccyy
  661.  
  662.           rem determine if this year is a leapyear
  663.           FDATE /Ff /At /OLY
  664.  
  665.  
  666.  
  667.  
  668. tttt      When used in place of a 4-digit CCYY string, "tttt"
  669.           will cause Fdate to use today's 4-digit year (CCYY).
  670.  
  671. tt        When used in place of a 2-digit DD, MM, or YY string,
  672.           "tt" will cause Fdate to use today's day-of-the-month,
  673.           month, or 2-digit year, respectively.
  674.  
  675.           Note that "tt" can NOT be used for the YY portion of a CCYY
  676.           input year.  The following, for example, is NOT valid:
  677.                FDATE /Ff /Imm-dd-ccyy /A01-01-19tt /Od1
  678.  
  679. EXAMPLES:
  680.  
  681.      FDATE /Ff /Imm-dd-ccyy /A01-01-tttt
  682.      FDATE /Ff /Imm-dd-yy   /A01-01-tt 
  683.  
  684.      rem report the 15th day of this month, this year
  685.      FDATE /Ff /Imm-dd-ccyy /Att-15-tttt
  686.  
  687.      rem Show the first Monday in the second quarter of this year
  688.      FDATE /Fw /Iccyymmdd /Atttt0401 /D2 /N1  /P"First Monday in QTR#2: "
  689.  
  690.      rem Show the last Friday on/before the 15th of this month.
  691.      FDATE /Fw /Iccyymmdd /Atttttt15 /D6 /N-1 /P"Friday before the 15th: "
  692.  
  693.  
  694. INPUT DATE FORMATS
  695. ==================
  696.  
  697.  
  698. CALENDAR DATE INPUT FORMATS
  699. ===========================
  700.  
  701. FORMAT      EXAMPLES      DISCUSSION
  702. ------      ---------     -----------------------------
  703. ccyymmdd    19922002  
  704.  
  705.  
  706. On the /I (input format) parm, the separator character of the following
  707. input formats must be a dash.  This simply tells Fdate that the input
  708. date will contain SOME separator character.  The separator character that
  709. actually occurs in dates in the /A and /B parms is ignored, and may be
  710. any non-numeric character: a slash "/", a dash "-", a dot ".", etc.
  711.  
  712. In specifications that begin with "mm-dd" or "dd-mm", leading zeros need
  713. not be present in the "mm" and "dd" part of the date.
  714.  
  715. ccyy-mm-dd  1992-02-20    Leading zeros MUST be present, since the
  716.             1992/02/20    date does not begin with dd-mm or mm-dd.    
  717.             1992.02.20    
  718.  
  719.  
  720. mm-dd-ccyy  02-20-1992    
  721.             02/20/1992    The dash represents ANY non-numeric character.
  722.  
  723.              2-5-1992     Leading zeros need not be present.
  724.              2/5/1992
  725.  
  726. mm-dd-yy    02-05-92      February 5, 1992.  See discussion of
  727.              2/5/92       FDATE'S CENTURY ASSUMPTION ALGORITHM, below
  728.  
  729.                           ---------------------------------------
  730.                           In the following formats, days
  731.                           precede months  (European style)
  732.                           ---------------------------------------
  733.  
  734. dd-mm-ccyy  05-02-1992 
  735.             05/02/1992 
  736.  
  737.              5-2-1992     Leading zeros need not be present.
  738.              5/2/1992
  739.  
  740. dd-mm-yy    05-02-92      February 5, 1992.  See discussion of
  741.              5/2/92       FDATE'S CENTURY ASSUMPTION ALGORITHM, below
  742.  
  743. BUSINESS JULIAN DATE INPUT FORMATS
  744. ==================================
  745.  
  746. These are formats for "business julian" dates: dates expressed as the
  747. number of days from the beginning of the year, when January 1 is day 1.
  748.  
  749. EXAMPLES:
  750.  
  751.       date      BUSINESS JULIAN DATE
  752.   -----------   --------------------
  753.   Jan  5, 1992  92005
  754.   Jan  5, 1993  93005
  755.   Dec 31, 1993  93365  [Dec 31 is 365th day of year 1993]
  756.   Dec 31, 1996  96366  [Dec 31 is 366th day, because 1996 is a leap year]
  757.  
  758. -----------------------------------------------------------------------
  759. NOTE:   * JJJ can be 1 - 4 digits
  760.         * may include a prefix of a plus or minus ( + or - ) sign
  761. -----------------------------------------------------------------------
  762.  
  763. FORMAT      EXAMPLES      DISCUSSION
  764. ------      ---------     -----------------------------
  765. ccyyjjj     1992003       Third day of 1992, i.e. Jan 3, 1992
  766.             19923         Third day of 1992
  767.             tttt003       Third day of this year
  768.             tttt3         Third day of this year
  769.  
  770.   yyjjj       92003       Third day of 1992
  771.               923         Third day of 1992
  772.               tt003       Third day of this year
  773.               tt3         Third day of this year
  774.               01003       Third day of 2001           See
  775.                           FDATE'S CENTURY ASSUMPTION ALGORITHM, below
  776.  
  777. NOTE THAT FDATE WILL ACCEPT "JJJ" OF LESS THAN 1 & MORE THAN 366.
  778. -----------------------------------------------------------------
  779.  
  780.   yyjjj       tt1000      the 1000th day from beginning of this year
  781.               tt0         last day of last year
  782.               tt-1        next-to-last day of last year
  783.  
  784. FDATE /Ff /Iccyyjjj /Od1 /A1992-1  produces... Monday December 30, 1991
  785. FDATE /Ff /Iccyyjjj /Od1 /A19920   produces... Tuesday December 31, 1991
  786. FDATE /Ff /Iccyyjjj /Od1 /A1992+1  produces... Wednesday January 1, 1992
  787.  
  788. FDATE /Ff /Iccyyjjj /Od1 /A1992366 produces... Thursday December 31, 1992
  789. FDATE /Ff /Iccyyjjj /Od1 /A1992367 produces... Friday January 1, 1993
  790.  
  791. This feature allows limited date arithmetic with ordinary business
  792. Julian days.  For example, 90 days from tt300 can be shown by:
  793.  
  794.                   FDATE /Ff /Iyyjjj /Att390
  795.  
  796. GETTING DATE/TIME A FILE WAS CREATED
  797. ====================================
  798.  
  799. FORMAT      EXAMPLES      DISCUSSION
  800. ------      ---------     -----------------------------
  801. f           MYFILE.1      Input format F (file) tells Fdate that
  802.                           /A and /B will specify filenames, and that
  803.                           Fdate should pick up the input date and time
  804.                           from the date/time stamp on a file.
  805.  
  806.      Note that if you specify /If, then both /A and /B will be interpreted
  807.      as filenames.
  808.  
  809.      It is not possible to put a filename in /A and a date literal in /B,
  810.      and then use the "comp" or "dif" function to compare them.  You must
  811.      first extract the file's date into an environment variable, and then
  812.      compare that environment variable to the date literal.
  813.  
  814.           The only exception to this rule is the pseudodate "t" (i.e. /At
  815.           or /Bt) which will pick up the current date and time from the
  816.           system clock.  This feature will allow you, for example, to
  817.           compare the date of a file to today's date (see EXAMPLES).
  818.  
  819.      A filename may (but need not) be fully qualified: i.e. "MYFILE.1" and
  820.      "C:\DBASE\WORKDIR\MYFILE.1" are both acceptable.
  821.  
  822.      A filename may contain wildcards.  If it does, the date/time stamp
  823.      will be retrieved from the first file that FDATE finds that meets the
  824.      filespec.  Giving FDATE a filespec containing a wildcard is pretty
  825.      useless, but FDATE will not reject it.
  826.  
  827. OUTPUT DATE FORMATS
  828. ===================
  829.  
  830. FORMAT        EXAMPLES      DISCUSSION
  831. ------        ---------     -----------------------------
  832. dd-mn3-yy     08-Feb-92     CompuServe-style date
  833.   yy            93          2-digit year number
  834. ccyy          1993          4-digit year number (includes century)
  835. ccyymm        199302        useful for triggering monthly processing
  836. ccyymmdd      19930208      useful for putting current date in filename
  837.   yymmdd        908208      useful for putting current date in filename
  838.     mmdd          0208
  839.       mm            02      2-digit month number
  840.       zm             2      month number, no leading zeros
  841.       dd            08      2-digit day-of-month number
  842.       zd             8      day-of-month number, no leading zeros
  843.  
  844. In the following formats, months precede days (American style)
  845. ------------------------------------------------------------------
  846. mm/dd/ccyy    02/08/1993
  847. mm-dd-ccyy    02-08-1993
  848. mm.dd.ccyy    02.08.1993    British-style dates
  849.  
  850. zm/zd/ccyy     2/8/1993     no leading zeros in day or month
  851. zm-zd-ccyy     2-8-1993     no leading zeros in day or month
  852. zm.zd.ccyy     2.8.1993     British-style dates
  853.  
  854. mm/dd/yy      02/08/92
  855. mm-dd-yy      02-08-92
  856. mm.dd.yy      02.08.92      British-style dates
  857.  
  858. zm/zd/yy       2/8/92       no leading zeros in day or month
  859. zm-zd-yy       2-8-92       no leading zeros in day or month
  860. zm.zd.yy       2.8.92       no leading zeros in day or month
  861.  
  862. In the following formats, days precede months  (European style)
  863. ------------------------------------------------------------------
  864. dd/mm/ccyy    02/08/1993
  865. dd-mm-ccyy    02-08-1993
  866. dd.mm.ccyy    02.08.1993    British-style dates
  867.  
  868. zd/zm/ccyy     2/8/1993     no leading zeros in day or month
  869. zd-zm-ccyy     2-8-1993     no leading zeros in day or month
  870. zd.zm.ccyy     2.8.1993     British-style dates
  871.  
  872. dd/mm/yy      02/08/92
  873. dd-mm-yy      02-08-92
  874. dd.mm.yy      02.08.92      British-style dates
  875.  
  876. zd/zm/yy       2/8/92       no leading zeros in day or month
  877. zd-zm-yy       2-8-92       no leading zeros in day or month
  878. zd.zm.yy       2.8.92       British-style dates
  879.  
  880. DAY-OF-WEEK AND MONTH OUTPUT FORMATS
  881. ====================================
  882.  
  883. dow#           5            Sunday=1, Monday=2 .... Saturday=7.
  884.  
  885. dow            Thursday     name of day of week
  886.                Jeudi        if /Lfr specified
  887.                Donnerstag   if /Lgr specified
  888.  
  889. dow3           Thu          first 3 characters of name of day of week
  890.                Jeu          if /Lfr specified
  891.                Don          if /Lgr specified
  892.  
  893. mn             February     name of month
  894.                Fevrier      if /Lfr specified
  895.                Februar      if /Lgr specified
  896.  
  897. mn3            Feb          first 3 characters of name of month
  898.                Fev          if /Lfr specified
  899.                Feb          if /Lgr specified
  900.  
  901.  
  902.  
  903.  
  904.  
  905. MISCELLANEOUS OUTPUT FORMATS
  906. ============================
  907.  
  908. full          9:05 pm on Wednesday February 5, 1992
  909.               9:05 pm, le Mercredi 5 Fevrier, 1992  [/Lfr specified]
  910.               9:05 pm, el miércoles 5 febrero, 1992 [/Lsp specified]
  911.               Mittwoch, 5. Februar 1992, 21:05     [/Lgr specified]
  912.  
  913. d1            Saturday, February 5, 1992
  914.               le Samedi 5 Fevrier 1992      [/Lfr specified]
  915.               Mittwoch, 5. Februar 1992     [/Lgr specified]
  916.  
  917. ddmn3yy       05Feb92
  918.  
  919. -----------------------------------------------------------------------
  920. NOTE that the following formats contain embedded spaces.  Consequently
  921. they must be enclosed in double quotes. EXAMPLE: /O"mn zd, ccyy".
  922. -----------------------------------------------------------------------
  923. "zd mn ccyy"      5 February 1992
  924. "zd mn, ccyy"     5 February, 1992
  925. "zd. mn ccyy"     5. February 1992   [German-style date format]
  926. "zd. mn3 ccyy"    5. Feb 1992        [German-style date format]
  927. "mn3 dd ccyy"     Feb 05 1992
  928. "mn3 dd, ccyy"    Feb 05, 1992
  929. "mn zd, ccyy"     February 5, 1992
  930.  
  931.  
  932.  
  933. LEAP-YEAR FLAG OUTPUT FORMAT
  934. ============================
  935.  
  936. LY              0     "1" if date occurs in a leapyear, otherwise "0".
  937.  
  938.                  365 + this number gives total number of days in the year.
  939.                   28 + this number gives total number of days in February.
  940.  
  941.  
  942.  
  943.  
  944. TIME OUTPUT FORMATS
  945. ===================
  946. See also: the section on the /T (parm /A time override) parameter.
  947.  
  948. t1            9:05 am
  949.               9:05 pm
  950.  
  951. HH:MM        09:05      24-hour time, hours:minutes
  952.              21:05
  953. HHMM         0905
  954.              2105
  955.  
  956. HH:MM:SS     21:05:30   24-hour time, hours:minutes:seconds
  957. HHMMSS       210530
  958.  
  959.  
  960. BUSINESS JULIAN DATE OUTPUT FORMATS
  961. ===================================
  962.  
  963. These are formats for "business julian" dates: dates expressed as the
  964. number of days from the beginning of the year, when January 1 is day 1.
  965.  
  966. EXAMPLES:
  967.  
  968.       DATE      BUSINESS JULIAN DATE
  969.   -----------   --------------------
  970.   Jan  5, 1993  93005
  971.   Dec 31, 1993  93365  [Dec 31 is 365th day of year 1993]
  972.   Dec 31, 1996  96366  [Dec 31 is 366th day, because 1996 is a leap year]
  973.  
  974.  
  975. FORMAT        EXAMPLES      DISCUSSION
  976. ------        ---------     -----------------------------
  977.  
  978. ccyyjjj       1992027       Jan 27, 1992
  979.   yyjjj         92027       "Business Julian" date expressed as number
  980.     jjj           027       of days since January 1 of the same year.
  981.     zzj            27       Note leading zero suppression in "zzj".
  982.  
  983.  
  984. ABSOLUTE DATE/TIME OUTPUT FORMATS
  985. =================================
  986. See also: the section on the /T (parm /A time override) parameter.
  987.  
  988.  
  989. day#           727198       "Absolute date": date expressed as number
  990.                             of days since January 1, 0001.
  991.  
  992. minute#         33088       "Absolute minutes": time expressed as number
  993.                             of minutes  since midnight, January 1, 1990.
  994.  
  995. second#        633088       "Absolute seconds": time expressed as number
  996.                             of seconds  since midnight, January 1, 1990.
  997.  
  998.  
  999. Running FDATE with /O parameter for an "absolute time" produces a
  1000. number based on the current time of day and the date in the /A parm.
  1001.  
  1002. If, on January 10, 1992 at 2 pm, you run FDATE this way:
  1003.        FDATE /Ff /Atoday /Ominute#
  1004. it will produce the absolute minute for January 10, 1992 at 2 pm.
  1005.  
  1006. If, on January 10, 1992 at 2 pm, you run FDATE this way:
  1007.        FDATE /Ff /A01-15-1992 /Imm-dd-ccyy  /Ominute#
  1008. it will produce the absolute minute for January 15, 1992 at 2 pm.
  1009.  
  1010.  
  1011. /T: TIME OVERRIDE PARAMETER
  1012. ===============================
  1013.  
  1014. You may override Fdate's use of the current time -- for the /A parameter
  1015. only -- by using the /T parameter.  The /T parameter specifies a time of
  1016. day in the 24-hour format hh:mm:ss (hours:minutes:seconds).  Leading zeros
  1017. in each of the three fields (hh, mm, ss) may be omitted.  The seconds field
  1018. may be omitted; if omitted, it defaults to "00".
  1019.  
  1020. Note that the /T parm overrides the time portion of the /A date, but it
  1021. does NOT override the time portion of the /B date.
  1022.  
  1023. If, on January 10, 1992 at 2 pm, you run FDATE this way:
  1024.        FDATE /Ff /A01-15-1992 /Imm-dd-ccyy  /Ominute#  /T5:12
  1025. it will produce the absolute minute for January 15, 1992 at 5:12 am.
  1026.  
  1027. The most frequent and important use of the /T parm is with the format
  1028. function (/Ff) to obtain the "absolute" minute of a specific date and time. 
  1029. Once we have the absolute minutes of two different date/times, we can
  1030. easily obtain the time between them (expressed in days, hours, and minutes)
  1031. by using Fdate's #dif, #idiv, and #mod functions.  (In the EXAMPLES
  1032. section, see the example that contains FORATIME.BAT.)
  1033.  
  1034. It is also possible to use /T in conjunction with the time compare function
  1035. (/Ftcomp).
  1036.  
  1037. @echo ON
  1038. cls
  1039. rem  Since both /A and /B default to the current date and time,
  1040. rem  and since /T parm overrides the time only for the /A parm ...
  1041.  
  1042. rem   ... during daytime hours, this will always return LT
  1043. Fdate /ftcomp /T00:00:00
  1044. rem   ... during daytime hours, this will always return GT
  1045. Fdate /ftcomp /T23:59:59
  1046.  
  1047.  
  1048. HOW TO PUT FDATE OUTPUT INTO AN ENVIRONMENT VARIABLE
  1049. ====================================================
  1050.  
  1051.  
  1052. CALL A BATCH FILE
  1053. =================
  1054.  
  1055.   The most basic way to put FDATE's output into an environment variable is
  1056.   to:
  1057.   *  use the /P (prefix string) feature to create a DOS "SET" statement,
  1058.   *  redirect the output to a batch file, and then
  1059.   *  CALL the batch file.  
  1060.  
  1061.   Since CALL first appeared in DOS 3.3, you will need DOS 3.3 or greater
  1062.   to use this technique.
  1063.  
  1064.        FDATE /Ff /Atoday /O"mn zd, ccyy" /P"@SET FDATE=" >JUNKTEMP.BAT
  1065.        call JUNKTEMP.BAT
  1066.        del  JUNKTEMP.BAT
  1067.  
  1068.  
  1069.  
  1070. USE AN ENVIRONMENT-MANIPULATION UTILITY
  1071. =======================================
  1072.  
  1073.   There are shareware and public domain utilities that are written
  1074.   specifically to manipulate environment variables, and do that job very
  1075.   well.  FDATE's output can be put into an environment variable by piping
  1076.   it to one of these utilities.  When piping FDATE output to a utility,
  1077.   you can prevent the output from being ECHOed to the screen by
  1078.   redirecting the output to NUL.
  1079.  
  1080.   Of these utilities, I can especially recommend Bob Stephan's GET
  1081.   (because it is very powerful and flexible) and PC Magazine's STRINGS
  1082.   (because it is free to ZiffNet members).  See the EXAMPLES section for
  1083.   examples of how to use STRINGS and GET to put FDATE's output into an
  1084.   environment variable.
  1085.  
  1086.      As of February 14, 1992, the current version of GET is 2.5.  On
  1087.      CompuServe, use IBMFF to look for GET*.ZIP (e.g. GET25.ZIP for version
  1088.      2.5) in CIS:IBMSYS, or for GET.ZIP in ZNT:UTILFORUM, lib 16.  GET is
  1089.      also available from the Public Software Library in Houston.
  1090.  
  1091.      As of February 14, 1992, the current version of STRINGS is 1.3. On
  1092.      CompuServe, look for STRING.ZIP in the PC Magazine Utilities Lib of
  1093.      ZNT:UTILFORUM.  STRHYP.ZIP contains good hypertext documentation on
  1094.      STRINGS.
  1095.  
  1096.  
  1097. FDATE'S /V PARAMETER
  1098. ====================
  1099.  
  1100.   Manipulating the environment is an incredibly tricky business.  There
  1101.   are questions of the local versus master environment, the version of DOS
  1102.   you are running, and the environment under which you are running (DOS,
  1103.   Windows, Carousel).  In order to keep FDATE focussed on date-related
  1104.   issues, versions of Fdate prior to 6.1 did not attempt to put output
  1105.   directly into an environment variable.  Instead, FDATE's output was
  1106.   written to standard output, that is, it was displayed on the screen.
  1107.   Output could then be redirected to a batch file, or piped to a utility
  1108.   (such as STRINGS or GET), that would put the output into an environment
  1109.   variable.
  1110.  
  1111.   Starting with version 6.1, Fdate supports a /V (environment variable)
  1112.   parameter.  A user can use /V to tell Fdate to put its output directly
  1113.   into an environment variable. (Fdate attempts to put output into an
  1114.   environment variable in the master, rather than the local, environment.)
  1115.  
  1116.   NOTE that due to the complexities of manipulating the environment, there
  1117.   may be circumstances where /V doesn't work.  These include running FDATE
  1118.   when you have shelled out to DOS from another program, have put the
  1119.   command processor in upper memory (UMB) (see below), are running under
  1120.   Windows, Carousel, etc.  In such cases, you may be able to use one of
  1121.   the more basic techniques described above.  For a list of environments
  1122.   in which the /V option has been reported as NOT working, see the next
  1123.   section.
  1124.  
  1125.  
  1126.  
  1127.   /Vevar tells Fdate to put output into an environmental variable whose
  1128.   name is "evar".  For example:
  1129.  
  1130.                 Fdate /Ff /Vdate1
  1131.  
  1132.   will set the environment variable DATE1 to the current date.  If you
  1133.   type SET at the DOS prompt, you should see something like:
  1134.  
  1135.                 DATE1=Friday February 14, 1992
  1136.  
  1137.   If you specify /V without an evar name, the evar name defaults to FDATE.
  1138.  
  1139.      Example :       Fdate /Ff /V
  1140.      produces:       FDATE=Friday February 14, 1992
  1141.  
  1142.   If you do not use /V, Fdate output is written to standard output, i.e.
  1143.   to the screen.
  1144.  
  1145. /V WHEN USING 4DOS, NDOS, AND UMB
  1146. =================================
  1147.     --------------------------------------------------------------
  1148.     I have received the following report from Aran Spence about
  1149.     circumstances in which FDATE /V will not set a variable
  1150.     in the master environment.  This report leads me to believe
  1151.     that FDATE /V may also fail to work with MS-DOS if you put
  1152.     the command processor or the environment in Upper Memory.
  1153.     --------------------------------------------------------------
  1154. Steve,
  1155.  
  1156. There are options with 4DOS and NDOS to load the environment and part
  1157. of the command processor into upper memory blocks.  When one of these
  1158. options is used, FDATE /V can't find the environment and produces the
  1159. message:
  1160.  
  1161.    ERROR
  1162.    echo ERROR: Master environment not found
  1163.    pause
  1164.  
  1165. If you have a 4DOS.INI file, it has to contain these lines for FDATE /V
  1166. to work:
  1167.  
  1168.    UMBEnvironment = No
  1169.    UMBLoad = No
  1170.  
  1171. If you have NDOS, the SHELL statement in CONFIG.SYS cannot contain
  1172. any reference to UMB loading via /U (which puts NDOS.COM in UMB), nor
  1173. can it contain a statement of the form:
  1174.                 /E:xxxU
  1175. (which puts xxx bytes of the environment in UMB via the "U" parameter).
  1176.  
  1177. Also, NSTART.BTM or 4START.BTM cannot contain
  1178.          SET NDSHELL=/e+xxxU /U
  1179. in which both U's represent UMB loading of the command processor and the
  1180. environment during secondary shells.
  1181.  
  1182. FDATE'S ERROR HANDLING
  1183. ======================
  1184.  
  1185.    If FDATE detects an error:
  1186.  
  1187.      (1) it will return an errorlevel of 1 (rather than 0), and
  1188.      (2) its output will be 3 lines:
  1189.        * the word ERROR
  1190.        * a DOS batch-file ECHO statement that displays an error message
  1191.        * a DOS batch-file PAUSE statement
  1192.  
  1193.    If Fdate output is displayed directly, or redirected to NUL,
  1194.    you can detect an error by testing the errorlevel for a value of 1.
  1195.  
  1196.    If Fdate output is piped to an environment manipulation utility such
  1197.    as STRINGS or GET, the environment variable will be set to ERROR.
  1198.    Errorlevel will be set by STRINGS/GET, and will probably be 0.
  1199.    In such a case, the only way to detect an error is to test the
  1200.    environment variable for the value ERROR.
  1201.  
  1202.    If FDATE output is redirected to a batch file, which is then
  1203.    CALLed to set an environment variable, the batch file will:
  1204.      * set the environment variable to ERROR,
  1205.      * ECHO the error message, and
  1206.      * pause.
  1207.    You can detect an error by testing errorlevel for the value 1
  1208.    either before or after you CALL the batch file, or 
  1209.    by testing the environment variable for the
  1210.    value ERROR, AFTER you have CALLed the batch file.
  1211.  
  1212. ----------------------------------------------------------------------
  1213.  
  1214.  EXAMPLE:
  1215.    rem use FDATE to check validity of year in parm %1
  1216.    Fdate /Fv /Imm-dd-ccyy /ATT-TT-%1 > nul
  1217.    if errorlevel 1 echo Year parm [%1] is not valid.
  1218.    if errorlevel 1 goto endit
  1219.  
  1220.  EXAMPLE:
  1221.    rem use FDATE to validate %1, and GET to put it into %year%
  1222.    Fdate /Ff /Imm-dd-ccyy /ATT-TT-%1 /Occyy | GET ZE /V%year% >nul
  1223.    if (%year%)==(ERROR) echo Year parm [%1] is not valid.
  1224.    if (%year%)==(ERROR) goto endit
  1225.  
  1226.  EXAMPLE:
  1227.    rem use FDATE to validate %1, call a batch file to put it into %year%
  1228.    Fdate /Ff /Imm-dd-ccyy /ATT-TT-%1 /Occyy /P"@set year=">junktemp.bat
  1229.    call junktemp.bat
  1230.    del  junktemp.bat
  1231.    if errorlevel 1 echo Year parm [%1] is not valid.
  1232.    if errorlevel 1 goto endit
  1233.  
  1234. EXAMPLES OF HOW TO USE FDATE
  1235. ============================
  1236.  
  1237. :01 Display Fdate output on screen
  1238. :==================================================================
  1239. FDATE /Ff /At /Od1 /P"Today is "
  1240.  
  1241.  
  1242. :02 Redirect FDATE output to a file
  1243. :==================================================================
  1244. FDATE /Ff /At /Od1 /P"Today is " >FDATE.OUT
  1245.  
  1246.  
  1247. :03 Put FDATE output in an environment variable using a batch file
  1248. :==================================================================
  1249. FDATE /Ff /Atoday /O"mn zd, ccyy" /P"@SET DATE1=" >JUNKTEMP.BAT
  1250. call JUNKTEMP.BAT
  1251. del  JUNKTEMP.BAT
  1252.  
  1253.  
  1254. :04 Put FDATE output in an environment variable using /V parm
  1255. :==================================================================
  1256. FDATE /Ff /Atoday /O"mn zd, ccyy" /Vdate1
  1257.  
  1258.  
  1259. :05 Put FDATE output in an environment variable using STRINGS
  1260. :==================================================================
  1261. FDATE /Ff /Atoday /O"mn zd, ccyy" |STRINGS date1= ASK >NUL
  1262.  
  1263.  
  1264. :06 Put FDATE output in an environment variable using GET
  1265. :==================================================================
  1266. FDATE /Ff /Atoday /O"mn zd, ccyy" |GET ZE /Vdate1 >NUL
  1267.  
  1268.  
  1269. :07 Change a date from one format into another
  1270. :==================================================================
  1271. FDATE /Ff /Imm-dd-yy /A05-08-92 /Occyymmdd
  1272.  
  1273.  
  1274. :11 Find the difference in days between two dates
  1275. :==================================================================
  1276. FDATE /Fdif /Imm-dd-ccyy /A%date1% /B%date2% /vdiff
  1277. echo The difference is %diff% days.
  1278.  
  1279.  
  1280.  
  1281.  
  1282. :12 Find the elapsed days/hours/minutes between two date/times.
  1283. :===================================================================
  1284. This batch file was developed in cooperation with Walter Ledge, a sysop for
  1285. CompuServe's CRFORUM.  In addition to being a good example of how to use
  1286. Fdate's /T parm and "#idiv" function, it should be useful for other
  1287. CompuServe sysops who need to submit the same reports that Walt does. 
  1288. Here's Walt's message that started the whole thing.
  1289.  
  1290.   As an assistant sysop on the CRFORUM, I have to submit reports to CIS on
  1291.   the number of messages that are posted on our forum in terms of time per
  1292.   1,000 messages -- i.e., say, I know that 1,000 messages were posted
  1293.   between the hours of 17:05 on July 5 and 3:03 on July 7.  I need to know
  1294.   how many hours and minutes it took for those 1000 messages to be posted. 
  1295.   So I would like some way to use FDATE to calculate the difference
  1296.   between those two times (which, of course, include the dates).
  1297.  
  1298. @echo off
  1299. cls
  1300. rem ------------------------------------------------------
  1301. rem FORATIME.BAT batch file parms
  1302. rem Dates must include full 4-digit for year: mm-dd-ccyy
  1303. rem Times must be in 24-hour format: hh:mm 
  1304. rem ------------------------------------------------------
  1305. set BEGdate=%1
  1306. set BEGtime=%2
  1307. set ENDdate=%3
  1308. set ENDtime=%4
  1309.  
  1310. ECHO Validating input parms ...
  1311. fdate /fv /A%BEGdate% /T%BEGtime%
  1312. if errorlevel 1 goto endit
  1313. fdate /fv /A%ENDdate% /T%ENDtime%
  1314. if errorlevel 1 goto endit
  1315.  
  1316. rem get absolute minute of start date/time
  1317. fdate /ff /ominute# /A%BEGdate% /T%BEGtime% /VABStime1
  1318. fdate /ff /ofull    /A%BEGdate% /T%BEGtime% /Vfull1
  1319.  
  1320. rem get absolute minute of end date/time
  1321. fdate /ff /ominute# /A%ENDdate% /T%ENDtime% /VABStime2
  1322. fdate /ff /ofull    /A%ENDdate% /T%ENDtime% /Vfull2
  1323.  
  1324. rem calculate the difference between ABStime1 and ABStime2
  1325. fdate /f#dif  /A%ABStime1% /B%ABStime2% /VMinutes
  1326. :
  1327. rem calculate the number of hours in it took
  1328. fdate /f#Idiv  /A%minutes% /B60  /VHours
  1329.  
  1330. rem calculate the number of extra minutes it took
  1331. fdate /f#mod   /A%minutes% /B60  /VMins
  1332.  
  1333. echo      Begin date time: %BEGdate% %BEGtime%
  1334. echo        End date time: %ENDdate% %ENDtime%
  1335. echo.
  1336. echo      It took %hours% hours and %mins% minutes
  1337. echo      between %full1%
  1338. echo          and %full2%
  1339. echo.
  1340.  
  1341. fdate /f#Idiv /A%minutes% /B1440 /Vday1
  1342. fdate /f#mod  /A%minutes% /B1440 /Vmin1
  1343. fdate /f#Idiv /A%min1%    /B60   /Vhour1
  1344. fdate /f#mod  /A%min1%    /B60   /Vmin2
  1345. echo      or, expressed another way ...
  1346. echo      a total of: %day1% day(s) %hour1% hour(s) and %min2% minute(s).
  1347. echo.
  1348. echo.
  1349.  
  1350. REM cleanup
  1351. set ENDdate=
  1352. set BEGdate=
  1353. set BEGtime=
  1354. set ENDtime=
  1355. set full1=
  1356. set full2=
  1357. set minutes=
  1358. set ABStime1=
  1359. set ABStime2=
  1360. set day1=
  1361. set hour1=
  1362. set min1=
  1363. set min2=
  1364. set mins=
  1365. set hours=
  1366. :endit
  1367.  
  1368.  
  1369. :13 Time the execution of a piece of software
  1370. :==================================================================
  1371. COMMENT
  1372.   This example was developed coded before the addition of the #div and
  1373.   #idiv functions to Fdate, so the run time (in minutes) is not calculated
  1374.   by dividing the run time (in seconds) by 60, as it now could be.
  1375.  
  1376. @echo off
  1377. cls
  1378. ECHO The demo will run for 1 - 60 seconds.
  1379. echo.
  1380. ECHO ─────────────────────────────────────────────────────────────────────
  1381. ECHO CALCULATE HOW LONG IT TOOK TO RUN A PROGRAM (in seconds and minutes)
  1382. echo.
  1383. echo If you leave long batch files to run overnight, this technique can
  1384. echo be used to record how long each program in the batch file ran.
  1385. echo.
  1386. echo The technique for setting the values of environment variables in this
  1387. echo part of the demo uses temporary batch files and CALL statements.
  1388. echo If you have a program such as GET or STRINGS, you can use it instead.
  1389. ECHO ──────────────────────────────────────────────────────────────────────
  1390. echo.
  1391. PAUSE
  1392. cls
  1393.  
  1394. FDATE /Ff /At /Ohh:mm:ss /P"TESTPGM simulated execution begins at "
  1395.  
  1396. REM  GET PROGRAM BEGIN TIME, IN MINUTES
  1397. @set BegM=
  1398. @set EndM=
  1399. @set RunM=
  1400. FDATE /Ff /At /Ominute# /P"SET BegM=" >FDATJUNK.BAT
  1401. CALL FDATJUNK.BAT
  1402.  
  1403. REM  GET PROGRAM BEGIN TIME, IN SECONDS
  1404. set BegS=
  1405. set EndS=
  1406. set RunS=
  1407. FDATE /Ff /At /Osecond# /P"SET BegS=" >FDATJUNK.BAT
  1408. CALL FDATJUNK.BAT
  1409.  
  1410. rem ───────────────────────────────────────────────────────────────
  1411. rem [simulate execution of a program: loop for a minute or less]
  1412. rem [In a real batch file, you would put your program statements here]
  1413. rem ───────────────────────────────────────────────────────────────
  1414. :BegLoop
  1415.    FDATE /Ff /At /Osecond# /P"SET EndS=" >FDATJUNK.BAT
  1416.    CALL FDATJUNK.BAT
  1417.    FDATE /Ff /At /Ominute# /P"SET EndM=" >FDATJUNK.BAT
  1418.    CALL FDATJUNK.BAT
  1419.  
  1420.    rem  calculate run time (difference between start time and end time)
  1421.    FDATE /F#dif /A%EndM% /B%BegM% /P"SET RunM=" > FDATJUNK.BAT
  1422.    CALL FDATJUNK.BAT
  1423.  
  1424.    rem  calculate run time (difference between start time and end time)
  1425.    FDATE /F#dif /A%EndS% /B%BegS% /P"SET RunS=" > FDATJUNK.BAT
  1426.    CALL FDATJUNK.BAT
  1427.    echo      TESTPGM running, elapsed time: %RunS% seconds
  1428.  
  1429.    if (%RunM%)==()  goto EndLoop
  1430.    if (%RunM%)==(0) goto BegLoop
  1431. :EndLoop
  1432. rem ───────────────────────────────────────────────────────────────
  1433.  
  1434. REM  GET PROGRAM END TIME IN SECONDS
  1435. FDATE /Ff /At /Osecond# /P"SET EndS=" > FDATJUNK.BAT
  1436. CALL FDATJUNK.BAT
  1437.  
  1438. REM  GET PROGRAM END TIME IN MINUTES
  1439. FDATE /Ff /At /Ominute# /P"SET EndM=" > FDATJUNK.BAT
  1440. CALL FDATJUNK.BAT
  1441.  
  1442. FDATE /Ff /At /Ohh:mm:ss /P"TESTPGM simulated execution ends at "
  1443. echo.
  1444.  
  1445. echo TESTPGM: Program end   time (Absolute seconds): %EndS%
  1446. echo TESTPGM: Program begin time (Absolute seconds): %BegS%
  1447. rem  calculate run time (difference between start time and end time)
  1448. FDATE /F#dif /A%EndS% /B%BegS% /P"TESTPGM: Run time in seconds= "
  1449. set BegS=
  1450. set EndS=
  1451.  
  1452. echo.
  1453. echo TESTPGM: Program end   time (Absolute minutes): %EndM%
  1454. echo TESTPGM: Program begin time (Absolute minutes): %BegM%
  1455. rem  calculate run time (difference between start time and end time)
  1456. FDATE /F#dif /A%EndM% /B%BegM% /P"TESTPGM: Run time in minutes= "
  1457. DEL  FDATJUNK.BAT
  1458. set BegM=
  1459. set EndM=
  1460. set RunM=
  1461. set RunS=
  1462.  
  1463. :15 Find calendar date corresponding to a "business Julian" date
  1464. :==================================================================
  1465. rem business julian date is 1992:045.  Note input format CCYYjjj
  1466. FDATE /Ff /A1992045  /Iccyyjjj  /Od1
  1467.  
  1468. rem You don't need to left-zero-fill the day
  1469. FDATE /Ff /A199245  /Iccyyjjj  /Od1
  1470.  
  1471. rem You can assume the century, if you specify the YYjjj input format
  1472. FDATE /Ff /A9245  /Iyyjjj  /Od1
  1473.  
  1474.  
  1475. :16 Set your PC's date to a business julian date
  1476. :==================================================================
  1477. @echo off
  1478. goto enddoc
  1479. ---------------------------------------------------------------------
  1480. JDATE.BAT
  1481. This batch file was created by Aran Spence [CIS: 70162,3044].  Its function
  1482. is to emulate the DOS DATE command, but to allow the user to set the date
  1483. using a business julian date format (yyjjj) instead of mm-dd-yy.
  1484.  
  1485. Note the format is YYjjj. This is the BUSINESS julian date: a date
  1486. expressed as the number of days from the beginning of the year, when
  1487. January 1 is day 1.
  1488.  
  1489.            date      BUSINESS julian date
  1490.        -----------   --------------------
  1491.        Jan 5, 1992       92005
  1492.        Jan 5, 1993       93005
  1493.        Dec 31, 1993      93365  [Dec 31 is 365th day of year 1993]
  1494.  
  1495. As Aran originally wrote it, the user-prompt was virtually identical to
  1496. that of the DATE command.  I have modified his original version, so it
  1497. now looks less like the DATE command but displays a bit more
  1498. information, and so it can operate from the command line even if the
  1499. user does not have GET.
  1500.  
  1501. If the user enters a business julian date as a command-line
  1502. parameter, JDATE resets the date to that julian date.
  1503.              EXAMPLE:  JDATE 92005
  1504. If there is no input parameter, GET is used to prompt the user for a
  1505. date.  It is possible to use JDATE even if you don't have GET by
  1506. operating only from the command line, or by substituting some other
  1507. utility (such as STRINGS) for GET.
  1508.  
  1509. Note that the user must enter both of the year digits (yy),
  1510. but may enter an abbreviated set of day digits (jjj).  That is,
  1511. for julian day 92005, the user is permitted to enter 925.
  1512.  
  1513. One handy use for JDATE is simply to find out what the current
  1514. business julian date is.
  1515. ---------------------------------------------------------------------
  1516. :enddoc
  1517.  
  1518. SET NewJD=%1
  1519. if not (%NewJD%)==() goto GotDate
  1520.  
  1521. :ShowDate
  1522. Fdate /Ff /Od1    /P"Current Gregorian date: "
  1523. Fdate /Ff /Oyyjjj /P"'Business Julian' date: "
  1524.  
  1525. :GetDate
  1526. GET S "Enter new date (yyddd): " /VNewJD /L
  1527. if (%NewJD%)==() goto endit
  1528.  
  1529. :GotDate
  1530. Fdate /Ff /A%NewJD% /Omm-dd-yy /Iyyjjj /P"@DATE " > JUNKTEMP.BAT
  1531. if errorlevel 1 if exist JUNKTEMP.BAT del JUNKTEMP.BAT
  1532. if errorlevel 1 echo Invalid date "%NewJD%"
  1533. if errorlevel 1 goto GetDate
  1534.  
  1535. rem  reset the date by calling JUNKTEMP.BAT
  1536. call JUNKTEMP.BAT
  1537. del  JUNKTEMP.BAT
  1538.  
  1539. echo SYSTEM DATE HAS BEEN RESET
  1540. Fdate /Ff /Od1    /P"Current Gregorian date: "
  1541. Fdate /Ff /Oyyjjj /P"'Business Julian' date: "
  1542.  
  1543. :endit
  1544. SET NewJD=
  1545. echo.
  1546.  
  1547.  
  1548. :18 Determine if parm %1 contains a valid date
  1549. :==================================================================
  1550. COMMENT
  1551.   Note that we throw away the FDATE output by redirecting it to NUL.  All
  1552.   we really want here is the errorlevel, which tells us whether or not the
  1553.   string in %1 is a valid year.
  1554.  
  1555. Fdate /Fv /Imm-dd-ccyy /A%1  >nul
  1556. if errorlevel 1 echo Parm 1 was not a valid date: %1
  1557. if errorlevel 1 goto endit
  1558.  
  1559. :
  1560. : Put the body of your batch file here.
  1561. :
  1562.  
  1563. :endit
  1564.  
  1565. :19 "Roll your own" date format 
  1566. :==================================================================
  1567. echo Display date in custom-made format: yymn3dd
  1568. Fdate /Ff /Oyy              /V
  1569. Fdate /Ff /Omn3 /P"%fdate%" /V
  1570. Fdate /Ff /Odd  /P"%fdate%" /V
  1571.  
  1572. echo Today is %fdate%
  1573. set fdate=
  1574.  
  1575.  
  1576.  
  1577. :20 Find the 4th Thursday in November (Thanksgiving)
  1578. :==================================================================
  1579. Fdate /Fw /D5 /N4 /A11-01-%year% /Imm-dd-ccyy /Od1 /P"Thanksgiving: "
  1580.  
  1581.  
  1582.  
  1583. :22 On a date, show what anniversary it is for some event
  1584. :==================================================================
  1585. See HOLIDAYS.BAT demo batch file
  1586.  
  1587.  
  1588.  
  1589. :23 Show a list of holidays in a given year
  1590. :==================================================================
  1591. See HOLIDAYS.BAT demo batch file
  1592.  
  1593.  
  1594. :24 Show a list of Federal holidays in a given year
  1595. :==================================================================
  1596. See HOLIFEDS.BAT demo batch file
  1597.  
  1598.  
  1599. :25 Determine if a year is valid, and evenly divisible by 4
  1600. :==================================================================
  1601.  
  1602. @echo off
  1603. cls
  1604. echo FUNCTION: Accept a year parm (CCYY) as parameter 1.  Determine if
  1605. echo the year is an election or inauguration year in the United States.
  1606. echo ===================================================================
  1607.  
  1608. rem verify %1 is a valid year
  1609. Fdate /Fv /Imm-dd-ccyy /A01-01-%1 >nul
  1610. if errorlevel 1 echo Year parm [%1] is not valid.
  1611. if errorlevel 1 goto endit
  1612.  
  1613. Fdate /Ff /Imm-dd-ccyy /A01-01-%1 /p"@set year=">junktemp.bat
  1614. call junktemp.bat
  1615.  
  1616. Fdate /F#mod /A%1 /B4 /p"@set mod=">junktemp.bat
  1617. call junktemp.bat
  1618. if (%mod%)==(0) echo %1 is an American presidential election year.
  1619. if (%mod%)==(1) echo %1 is an American presidential inauguration year.
  1620. for %%v in (2 3) do if (%mod%)==(%%v) echo %1 is not an election year.
  1621. for %%v in (2 3) do if (%mod%)==(%%v) echo %1 is not an inauguration year.
  1622.  
  1623. set mod=
  1624. :endit
  1625. if exist junktemp.bat del  junktemp.bat
  1626.  
  1627.  
  1628.  
  1629.  
  1630. :30 Compare a file's date to today's date
  1631. :==================================================================
  1632. rem Compare today's date to the date on the filename in %1
  1633. Fdate /Fcomp /At /If /B%1 /Vcomp
  1634. if (%comp%)==(EQ) echo %1 was created or updated today
  1635. set comp=
  1636.  
  1637. :32 Display a list of all files that were created/updated today. 
  1638. :==================================================================
  1639. COMMENT
  1640.   For a slightly more elaborate version of this same idea, see demo batch
  1641.   file FILEDATE.BAT
  1642.  
  1643. @echo off
  1644. if (%1)==(SUBROUTINE) goto %2
  1645.  
  1646. CLS
  1647. ECHO FILES MEETING FILESPEC [%1] THAT WERE CREATED OR UPDATED TODAY
  1648. REM  The batch file calls itself: Its own name is in parm %0
  1649. for %%v in (%1) do  CALL %0 SUBROUTINE CHECKFILE %%v
  1650.  
  1651. set comp=
  1652. del JUNKTEMP.BAT
  1653. goto endit
  1654.  
  1655. :CHECKFILE
  1656. rem Consume "SUBROUTINE"
  1657. shift
  1658. rem Consume "CHECKFILE"
  1659. shift
  1660.  
  1661. rem Now, %1 contains a filename parameter
  1662. rem Compare today's date to the date on the %1 file
  1663. Fdate /Fcomp /If /At /B%1 /P"@set COMP=">JUNKTEMP.BAT
  1664. CALL JUNKTEMP.BAT
  1665.  
  1666. rem Echo the filename if the file was created/updated today
  1667. if (%comp%)==(EQ) echo %1
  1668. :endit
  1669.  
  1670. :34 Loop through an array of environment variables
  1671. :======================================================================
  1672. @echo off
  1673. cls
  1674. SET pct=%%%
  1675. SET prefix=Address
  1676.  
  1677. ECHO LOADING AN ARRAY
  1678. SET subscript=1
  1679. SET %prefix%.%subscript%=Stephen Ferg
  1680. SET subscript=2
  1681. SET %prefix%.%subscript%=5113 N. 8th Road
  1682. SET subscript=3
  1683. SET %prefix%.%subscript%=Arlington, VA 22205
  1684.  
  1685. ECHO UNLOADING AND DISPLAYING THE ARRAY
  1686. SET subscript=1
  1687. :LoopTop
  1688. REM do while subscript less than/equal 3
  1689. if %subscript%==4 goto LoopEnd
  1690.  
  1691.    REM put value of subscripted variable into tempvar
  1692.    ECHO SET tempvar=%pct%%prefix%.%subscript%%pct%>JUNKTEMP.BAT
  1693.    CALL JUNKTEMP.BAT
  1694.  
  1695.    REM display value of subscripted variable
  1696.    ECHO %prefix%.%subscript% is: %tempvar%
  1697.  
  1698.    REM delete subscripted variable
  1699.    SET %prefix%.%subscript%=
  1700.  
  1701.    REM increment the loop variable
  1702.    Fdate /F#add /A%subscript% /B1 /Vsubscript
  1703.    goto LoopTop
  1704. :LoopEnd
  1705.  
  1706. SET pct=
  1707. SET tempvar=
  1708. SET prefix=
  1709. SET subscript=
  1710. DEL JUNKTEMP.BAT
  1711.  
  1712. :44 Do something on the last day (or last Friday) of the month
  1713. :==================================================================
  1714. COMMENT
  1715. We often need batch files that do some special task on the last day of the
  1716. month: run a backup job, display a reminder message, etc.  This example
  1717. batch file, LASTDAY.BAT, simply displays a message -- you can modify it to
  1718. do whatever it is that YOU want to do.
  1719.  
  1720. If you plan to run LASTDAY.BAT at work, and you work Monday through Friday,
  1721. then checking for the last day of the month would be a poor strategy --
  1722. after you leave work on a Friday, the last day of the month might occur on
  1723. the following Saturday or Sunday.   So I've included a check to see if the
  1724. Friday is the last working day of the month.  If you don't want that
  1725. functionality, deleting the lines between the first and last occurrence of
  1726. the string "EndCheck" will remove it.
  1727. =======================================================================
  1728.  @echo off
  1729.  REM ---------------------------------------------------------------
  1730.  REM check to see if today is the last day of the month
  1731.  REM ---------------------------------------------------------------
  1732.  REM get today's month
  1733.  fdate /ff        /omm /vmmtoday
  1734.  
  1735.  REM get tomorrow's month
  1736.  fdate /fadd /n1 /omm  /vmmtomorrow
  1737.  
  1738.  REM if tomorrow occurs in a different month,
  1739.  REM then today is the last day of this month
  1740.  if not (%mmtoday%)==(%mmtomorrow%) echo LAST DAY OF THE MONTH
  1741.  if not (%mmtoday%)==(%mmtomorrow%) goto EndCheck
  1742.  
  1743.  REM -------------------------------------------------------------
  1744.  REM check to see if today is the last Friday of the month
  1745.  REM -------------------------------------------------------------
  1746.  rem get today's day of the week, to see if it is Friday
  1747.  fdate /ff /odow3 /vdow3
  1748.  if not (%dow3%)==(Fri) goto EndCheck
  1749.  
  1750.  REM today is Friday.  Get next Monday's month
  1751.  fdate /fadd /n3 /omm  /vmmMonday
  1752.  
  1753.  REM if next Monday occurs in a different month,
  1754.  REM then today is the last Friday of this month
  1755.  if not (%mmtoday%)==(%mmMonday%) echo LAST WORKING DAY OF THE MONTH
  1756.  
  1757.  :EndCheck
  1758.  
  1759.  REM cleanup
  1760.  set dow3=
  1761.  set mmtoday=
  1762.  set mmtomorrow=
  1763.  set mmMonday=
  1764.  
  1765. :45 Get information about the month prior to the current month
  1766. :==================================================================
  1767. COMMENT
  1768. When running a monthly backup job at the beginning of the month, one often
  1769. needs to identify the previous month, or the last day of the previous
  1770. month.  Here's how to use Fdate to obtain that sort of information. 
  1771. Basically, we subtract one day from the first day of the current month,
  1772. giving us the last day of the previous month.
  1773. =======================================================================
  1774. @echo off
  1775. cls
  1776. : The simplest way to get information about last month is to subtract
  1777. : 1 day from the first day of this month ...
  1778.  
  1779. fdate /fsub /n1 /att-01-tttt /omm   /p"Last month was.................: "
  1780. fdate /fsub /n1 /att-01-tttt /occyy /p"Last month occurred in the year: "
  1781. fdate /fsub /n1 /att-01-tttt /odd   /p"The last day of last month was : "
  1782. fdate /fsub /n1 /att-01-tttt /od1   /p"The last day of last month was : "
  1783.  
  1784. :51 Represent a date in a short (4-byte) format (technique #1)
  1785. :==================================================================
  1786. COMMENT
  1787. A common use of Fdate is to format today's date and use it to rename a file
  1788. (typically a log file of some sort).  You may wish to store the date
  1789. information in as few characters as possible, in order to maximize the
  1790. number of other characters in the filename that you can use to store other
  1791. information.
  1792.  
  1793. In this example, and the next one, I illustrate two ways to store a date in
  1794. 4 bytes.
  1795.  
  1796.  
  1797. The simplest way is to represent today's date as a 4-digit number.
  1798. To do this, we first pick a base date:  I'll use January 1, 1990.
  1799. Then it is a simple matter to calculate the number of days between today
  1800. and the base date:
  1801.  
  1802.            FDATE /Fdif /at /b01-01-1990 
  1803.  
  1804. Starting in 1993, this will always generate a 4-digit number, and will
  1805. continue to do so for 20 years, until approximately the year 2003.  Dates
  1806. before 1993 may produce 1-, 2-, or 3-digit numbers, and dates after 2003
  1807. will begin to produce 5-digit numbers.  But this technique will work quite
  1808. nicely for most ordinary purposes for the next 20 years.  
  1809.  
  1810. If you're still using DOS in the year 2003, then in 2003 you can switch to
  1811. using January 1, 2000 as your base date and function quite nicely for the
  1812. next 20 years after that.
  1813.  
  1814.  
  1815. :52 Represent a date in a short (4-byte) format (technique #2)
  1816. :==================================================================
  1817.  
  1818. @echo off
  1819. cls
  1820.  
  1821. goto end-doc
  1822. ------------------------------------------------------------------
  1823. This batch file shows two ways to use Fdate and SetXX.BAT to
  1824. obtain and represent today's date in 4 characters, YYMD, where:
  1825.  
  1826.   YY is the year (e.g. "93" for 1993)
  1827.    M is the month in extended hexadecimal (XX) notation
  1828.    D is the day-of-the-month in extended hexadecimal (XX) notation
  1829.  
  1830. The text of SetXX.BAT, and an explanation of extended hex notation,
  1831. can be found in the next example.
  1832. ------------------------------------------------------------------
  1833. :end-doc
  1834.  
  1835. rem ----------------------------------------------------------------
  1836. rem          VERSION 1 (using JUNK.BAT temporary batch file)
  1837. rem ----------------------------------------------------------------
  1838.  
  1839. REM OBTAIN 1-CHARACTER REPRESENTATION FOR THE MONTH
  1840. fdate /ff /omm /p"@call SetXX xm ">junk.bat
  1841. call junk.bat
  1842. echo XX representation of this month's number      is %xm%
  1843.  
  1844. REM OBTAIN 1-CHARACTER REPRESENTATION FOR THE DAY
  1845. fdate /ff /odd /p"@call SetXX xd ">junk.bat
  1846. call junk.bat
  1847. echo XX representation of today's day of the month is %xd%
  1848.  
  1849. REM CONCATENATE THEM TO THE 2-CHARACTER REPRESENTATION FOR THE YEAR
  1850. fdate /ff /oyy /p"@set xx=" /s"%xm%%xd% >junk.bat
  1851. call junk.bat
  1852. echo XX representation of today's full date        is %xx%
  1853.  
  1854. REM CLEANUP
  1855. set xm=
  1856. set xd=
  1857. set xx=
  1858. del junk.bat
  1859.  
  1860. echo.
  1861. :
  1862. echo.
  1863. rem ----------------------------------------------------------------
  1864. rem          VERSION 2 (using JUNK environment variable)
  1865. rem ----------------------------------------------------------------
  1866.  
  1867. REM OBTAIN 1-CHARACTER REPRESENTATION FOR THE MONTH
  1868. fdate /ff /omm /p"call SetXX xm " /vjunk
  1869. %junk%
  1870. echo XX representation of this month's number      is %xm%
  1871.  
  1872. REM OBTAIN 1-CHARACTER REPRESENTATION FOR THE DAY
  1873. fdate /ff /odd /p"call SetXX xd " /vjunk
  1874. %junk%
  1875. echo XX representation of today's day of the month is %xd%
  1876.  
  1877. REM CONCATENATE THEM TO THE 2-CHARACTER REPRESENTATION FOR THE YEAR
  1878. fdate /ff /oyy /p"set xx=" /s"%xm%%xd%" /vjunk
  1879. %junk%
  1880. echo XX representation of today's full date        is %xx%
  1881.  
  1882. REM CLEANUP
  1883. set xm=
  1884. set xd=
  1885. set xx=
  1886. set junk=
  1887.  
  1888. echo.
  1889. echo.
  1890.  
  1891.  
  1892. :53 SetXX.BAT (used in the previous example)
  1893. :==================================================================
  1894. @echo off
  1895.  
  1896. goto end-doc
  1897. --------------------------------------------------------------------
  1898. "Extended hexadecimal" (XX) notation uses all of the digits, and
  1899. all of the letters of the alphabet, to express numbers in the range
  1900. of 0 to 35 as a single character.  This batch file converts a 2-digit
  1901. number in the range of 00 to 35 to xx notation.
  1902.  
  1903. This batch file expects 2 parameters:
  1904.  %1 contains the name of the environment variable that you
  1905.     want to use to hold the xx value
  1906.  %2 contains the 2-digit number that you want to convert to xx
  1907. --------------------------------------------------------------------
  1908. :end-doc
  1909.  
  1910. if (%2)==() goto endit
  1911. set %1=
  1912. if (%2)==(00) set %1=0
  1913. if (%2)==(01) set %1=1
  1914. if (%2)==(02) set %1=2
  1915. if (%2)==(03) set %1=3
  1916. if (%2)==(04) set %1=4
  1917. if (%2)==(05) set %1=5
  1918. if (%2)==(06) set %1=6
  1919. if (%2)==(07) set %1=7
  1920. if (%2)==(08) set %1=8
  1921. if (%2)==(09) set %1=9
  1922.  
  1923. if (%2)==(10) set %1=A
  1924. if (%2)==(11) set %1=B
  1925. if (%2)==(12) set %1=C
  1926. if (%2)==(13) set %1=D
  1927. if (%2)==(14) set %1=E
  1928. if (%2)==(15) set %1=F
  1929. if (%2)==(16) set %1=G
  1930. if (%2)==(17) set %1=H
  1931. if (%2)==(18) set %1=I
  1932. if (%2)==(19) set %1=J
  1933.  
  1934. if (%2)==(20) set %1=K
  1935. if (%2)==(21) set %1=L
  1936. if (%2)==(22) set %1=M
  1937. if (%2)==(23) set %1=N
  1938. if (%2)==(24) set %1=O
  1939. if (%2)==(25) set %1=P
  1940. if (%2)==(26) set %1=Q
  1941. if (%2)==(27) set %1=R
  1942. if (%2)==(28) set %1=S
  1943. if (%2)==(29) set %1=T
  1944. :
  1945. if (%2)==(30) set %1=U
  1946. if (%2)==(31) set %1=V
  1947. if (%2)==(32) set %1=W
  1948. if (%2)==(33) set %1=X
  1949. if (%2)==(34) set %1=Y
  1950. if (%2)==(35) set %1=Z
  1951.  
  1952. :endit
  1953.  
  1954.  
  1955. :54 Customize Fdate for a language of your choice
  1956. :==================================================================
  1957. @echo off
  1958. cls
  1959. goto end-doc
  1960. ------------------------------------------------------------------
  1961. You can use Fdate with a customized batch file to obtain the names of
  1962. the days of the week and the months in a language of your choice.  Or
  1963. you could use it to obtain names in uppercase, or the first 5
  1964. characters of the names (rather than the first three), or some other
  1965. customized formatting of your choice.)
  1966.  
  1967. I've invented a language called Fergian, which has its own names for
  1968. the days of the week, and the months.  In the following examples, I
  1969. invoke FERGIAN.BAT to make the translation.  The text of FERGIAN.BAT,
  1970. which does the real work here, is given in the next example.
  1971. ------------------------------------------------------------------
  1972. :end-doc
  1973.  
  1974. fdate /ff /omm /v
  1975. call Fergian mm- result %Fdate%
  1976. echo Month  is          %result%
  1977.  
  1978. fdate /ff  /omm /v
  1979. call Fergian mm3 result %Fdate%
  1980. echo Month3 is          %result%
  1981.  
  1982. fdate /ff /odow#  /v
  1983. call Fergian dw- result %Fdate%
  1984. echo Day of week  is    %result%
  1985.  
  1986. fdate /ff /odow#  /v
  1987. call Fergian dw3 result %Fdate%
  1988. echo Day of week3 is    %result%
  1989.  
  1990. REM cleanup
  1991. set Fdate=
  1992. set result=
  1993.  
  1994. :55 Fergian.BAT (used in the previous example)
  1995. :==================================================================
  1996. @echo off
  1997. set  %2=
  1998. goto %1
  1999.  
  2000. goto end-doc
  2001. --------------------------------------------------------------------
  2002. This batch file converts a month number, or day of the week number,
  2003. to a name in the FERGIAN language.
  2004. You can copy this batch file and customize it, to make it translate
  2005. into some other language of your choice.
  2006.  
  2007. This batch file expects the following parameters:
  2008.  
  2009. %1 contains the type of number you want to convert:
  2010.    MM- if you want the entire name of the month
  2011.    MM3 if you want the first 3 letters of the name of the month
  2012.  
  2013.    DW- if you want the entire name of the day of the week
  2014.    DW3 if you want the first 3 letters of the name of the day of the week
  2015.  
  2016. %2 contains the name of the environment variable that you
  2017.    want to use to hold the result
  2018.  
  2019. %3 contains the number that you want to convert
  2020. --------------------------------------------------------------------
  2021. :end-doc
  2022.  
  2023. :MM-
  2024. if (%3)==(01) set %2=Jaded
  2025. if (%3)==(02) set %2=Febrile
  2026. if (%3)==(03) set %2=Martial
  2027. if (%3)==(04) set %2=Abigail
  2028. if (%3)==(05) set %2=Maybelene
  2029. if (%3)==(06) set %2=Junkaroo
  2030. if (%3)==(07) set %2=Julia
  2031. if (%3)==(08) set %2=Augmentation
  2032. if (%3)==(09) set %2=Separation
  2033. if (%3)==(10) set %2=Ostentation
  2034. if (%3)==(11) set %2=Novelty
  2035. if (%3)==(12) set %2=Decadence
  2036. goto endit
  2037.  
  2038. :
  2039. :MM3
  2040. if (%3)==(01) set %2=Jad
  2041. if (%3)==(02) set %2=Feb
  2042. if (%3)==(03) set %2=Mar
  2043. if (%3)==(04) set %2=Abi
  2044. if (%3)==(05) set %2=May
  2045. if (%3)==(06) set %2=Jun
  2046. if (%3)==(07) set %2=Jul
  2047. if (%3)==(08) set %2=Aug
  2048. if (%3)==(09) set %2=Sep
  2049. if (%3)==(10) set %2=Ost
  2050. if (%3)==(11) set %2=Nov
  2051. if (%3)==(12) set %2=Dec
  2052. goto endit
  2053.  
  2054. :DW-
  2055. if (%3)==(1) set %2=SunDay
  2056. if (%3)==(2) set %2=MoonDay
  2057. if (%3)==(3) set %2=TwickasDay
  2058. if (%3)==(4) set %2=WodensDay
  2059. if (%3)==(5) set %2=ThorsDay
  2060. if (%3)==(6) set %2=FreyasDay
  2061. if (%3)==(7) set %2=SaturnDay
  2062. goto endit
  2063.  
  2064.  
  2065. :DW3
  2066. if (%3)==(1) set %2=Sun
  2067. if (%3)==(2) set %2=Moo
  2068. if (%3)==(3) set %2=Twi
  2069. if (%3)==(4) set %2=Wod
  2070. if (%3)==(5) set %2=Tho
  2071. if (%3)==(6) set %2=Fre
  2072. if (%3)==(7) set %2=Sat
  2073. goto endit
  2074.  
  2075.  
  2076. :endit
  2077.  
  2078. :61 DO-ONCE: Run apps when booting for the first time of the day
  2079. :===============================================================
  2080. COMMENT
  2081.   Put this code in AUTOEXEC.BAT.  Note that this batch code requires DOS
  2082.   3.3+, since it uses CALL.
  2083.  
  2084. if not exist C:\LASTRUN.BAT goto RunNow
  2085.  
  2086. rem call LASTRUN.BAT, which will set an environment variable, %LASTRUN%,
  2087. rem that will contain the date when this batch file was last run.
  2088. rem ------------------------------------------------------------------
  2089. call C:\LASTRUN.BAT
  2090.  
  2091. rem compare the date in %LASTRUN% to today's date
  2092. rem ------------------------------------------------------------------
  2093. Fdate /Fcomp /At /B%LastRun% /Vcomp
  2094.  
  2095. : Today's date may be less than %LASTRUN% if you reset the system clock
  2096. IF (%COMP%)==(LT) goto NoRun
  2097. : If %LASTRUN% was the same as today's date,
  2098. :   then this batch file has already been run once today
  2099. IF (%COMP%)==(EQ) goto NoRun
  2100.  
  2101. : Daily processing hasn't been run today. Run it.
  2102. : Here, you should put the batch-file body --
  2103. : the code to run the applications that you want to run once per day
  2104. :
  2105.  
  2106. : ------------------------------------------------------------------
  2107. : Save today's date in a new version of LastRun.BAT.  Note that
  2108. : this code will be executed only if daily processing runs to
  2109. : completion without hanging the machine or aborting the batch file.
  2110. : ------------------------------------------------------------------
  2111. Fdate /Ff /Omm-dd-ccyy /At /P"@set LastRun=">LastRun.BAT
  2112.  
  2113. :NoRun
  2114. set LastRun=
  2115. set COMP=
  2116.  
  2117. :62a Run specific software, depending on the day of the week
  2118. :==================================================================
  2119. COMMENT
  2120. This is a very common use for Fdate.  I use it to load alarm-clock software
  2121. that will beep at me -- at different times for different days of the week -
  2122. - to remind me that it is time to attend a regular weekly meeting that is
  2123. scheduled for that day of the week.
  2124.  
  2125. Note that stuff for a given day of  the week will be executed every time
  2126. you boot up on that day of the week.  That is what you want if, like me,
  2127. you are loading alarm-clock software.
  2128.  
  2129. If your application is different, and you want stuff for a given day of the
  2130. week to be run only once -- the first time you boot up each day --then
  2131. first copy the code from DO-ONCE (the previous example) into your
  2132. AUTOEXEC.BAT file, then put this code into AUTOEXEC.BAT in the body of the
  2133. DO-ONCE code.  If you do that, then this code will be run only once per
  2134. day, even if you boot up multiple times per day.
  2135.  
  2136. Remember that if you are executing other batch files from a batch file, 
  2137. you probably want to invoke them with a CALL statement:
  2138.               CALL batchfilename parm1 parm2 ...
  2139. so control will return to the calling batch file when execution of the
  2140. called batch file is complete.      
  2141. ========================================================================
  2142.  
  2143. rem get 3-character day-of-week name and put it in DOW e-var
  2144. FDATE /ff /oDOW3 /vDOW
  2145. goto %DOW%
  2146.  
  2147. :MON
  2148. :
  2149. : Here, put code to run stuff for this day of the week.
  2150. :    for example: CALL MONDAY.BAT 
  2151. :
  2152. goto END-DOW
  2153.  
  2154.  
  2155. :FRI
  2156. :
  2157. : Here, put code to run stuff for this day of the week.
  2158. :
  2159. goto END-DOW
  2160.  
  2161. rem do nothing on the following days -- fall through to END-DOW
  2162. :SAT
  2163. :SUN
  2164. :TUE
  2165. :WED
  2166. :THU
  2167. :END-DOW
  2168. set dow=
  2169.  
  2170. :62b Run specific software, depending on the day of the week
  2171. :==================================================================
  2172. COMMENT
  2173.   This is a variation on the last example.  Note that the string
  2174.   comparison is case sensitive.
  2175.  
  2176. rem get 3-character day-of-week name and put it in DOW e-var
  2177. FDATE /ff /oDOW3 /vDOW
  2178.  
  2179. if (%DOW%)==(Mon) echo Running regular Monday backup.  Please wait...
  2180. if (%DOW%)==(Mon) CALL BACKUP C: 
  2181. if (%DOW%)==(Mon) CALL BACKUP D:   
  2182. if (%DOW%)==(Mon) CALL BACKUP E:   
  2183. if (%DOW%)==(Mon) CALL BACKUP F:   
  2184.  
  2185. if (%DOW%)==(Thu) echo Running regular Thursday backup.  Please wait...
  2186. if (%DOW%)==(Thu) CALL BACKUP C: 
  2187. if (%DOW%)==(Thu) CALL BACKUP F: 
  2188. set dow=
  2189.  
  2190.  
  2191.  
  2192. :63 Run a program at a specified time later in the day
  2193. :==================================================================
  2194. COMMENT
  2195.   This batch file involves a lot of disk activity because DOS re-reads the
  2196.   batch file from disk every time it does a GOTO LOOPTOP.  You can avoid
  2197.   all this disk activity by running the batch file from a RAM DISK.
  2198.  
  2199. REM GET CURRENT ABSOLUTE MINUTE AND PUT IN ENVIRONMENT VARIABLE RUNTIME
  2200. FDATE /Ff /At /Ominute#  |STRINGS RunTime= ASK >NUL
  2201.  
  2202. REM ADD 120 MINUTES (2 HOURS) TO ENVIRONMENT VARIABLE RUNTIME
  2203. FDATE /F#add /A%RunTime% /B120 |STRINGS RunTime= ASK >NUL
  2204.  
  2205. REM LOOP UNTIL NOWTIME HAS REACHED RUNTIME
  2206. :LoopTop
  2207.   FDATE /Ff /At  /Ominute#   |STRINGS NowTime=  ASK >NUL
  2208.   FDATE /F#comp  /A%NowTime% /B%RunTime% |STRINGS TimeComp= ASK >NUL
  2209.   if (%TimeComp%)==(LT) goto loopTop
  2210. :LoopEnd
  2211.  
  2212. echo STARTING EXECUTION OF APPLICATION: [program name]
  2213.  
  2214.  
  2215.  
  2216. :67 Change a file's name to a name that contains today's date
  2217. :==================================================================
  2218. FDATE /Ff /Atoday /Oyymmdd /vdate1
  2219. ren  BACKUP.LOG  BK%DATE1%.LOG
  2220. SET  DATE1=
  2221.  
  2222.  
  2223.  
  2224. :68 Change a file's name to a name containing an absolute minute 
  2225. :===============================================================
  2226. COMMENT
  2227.   This is a way to keep a complete series of files, such as log files,
  2228.   that are all created with the same name on the same day.  The only
  2229.   requirement is that they be created at least one minute apart.  You
  2230.   won't need to be able to decipher the absolute minute to figure out when
  2231.   the file was created; you can simply do a DIR on the file and look at
  2232.   its date/time stamp.  
  2233.  
  2234. FDATE /FF /At /Ominute# /VJulMin
  2235. REN online.log %JulMin%.log
  2236. SET JulMin=
  2237.  
  2238. HOW FDATE THINKS ABOUT DATES
  2239. ============================
  2240.  
  2241. FDATE'S BUSINESS VIEW OF THE CALENDAR
  2242. =====================================
  2243.  
  2244.   FDATE is intended for business applications, not historical ones.  
  2245.  
  2246.   FDATE does not take into account historical changes in the calendar such
  2247.   as the ten days that were dropped from the British calendar when Britain
  2248.   moved from the Julian to the Gregorian calendar in the 18th century, or
  2249.   the 11 days that were dropped from the Russian calendar when Russia made
  2250.   the same move in the early 20th century.
  2251.  
  2252.   As far as FDATE is concerned, the calendar has followed the same
  2253.   pattern, unchanged, since January 1, 0001.
  2254.  
  2255.  
  2256. FDATE'S BASE DATE
  2257. =================
  2258.   Internally, Fdate's date manipulations are based on translating a
  2259.   calendar date into an "absolute" or "TRUE Julian" date:  a date
  2260.   expressed as the number of days from some day in the distant past.
  2261.  
  2262.   FDATE's base date is January 1, 0001 (i.e. day 1 of month 1 of year 1)
  2263.   FDATE's absolute date for January 1, 0001 is      1.
  2264.   FDATE's absolute date for January 1, 1992 is 727198.
  2265.  
  2266.  
  2267. FDATE'S LEAP YEAR ALGORITHM
  2268. ===========================
  2269.     Every year evenly divisible by 4 IS a leap year
  2270.       EXCEPT THAT
  2271.         Every year evenly divisible by 100 IS NOT a leap year
  2272.           EXCEPT THAT
  2273.             Every year evenly divisible by 400 IS a leap year
  2274.     .
  2275.     Using this algorithm
  2276.          1983  is not a leap year
  2277.          1984  is     a leap year
  2278.          1900  is not a leap year
  2279.          2000  is     a leap year
  2280.  
  2281.     See "A Machine Algorithm for Processing Calendar Dates", by
  2282.          Henry F. Fliegel (Georgetown University Observatory) and
  2283.          Thomas C. Van Flandern (U.S. Naval Observatory)
  2284.          COMMUNICATIONS OF THE ACM, Volume 11, Number 10, October 1968
  2285.  
  2286. There is supposedly a new adjustment to the leapyear algorithm,
  2287. which specifies the additional exception:
  2288.  
  2289.               EXCEPT THAT
  2290.                 Every year evenly divisible by 4000 IS a leap year
  2291.  
  2292. See "Bit By Bit" column, COMPUTER LANGUAGE, November 1989, p. 148.
  2293. This adjustment is not part of FDATE's leapyear algorithm.
  2294. Unless your application is working with dates 2,000 years in the
  2295. future, the lack of this exception will be irrelevant for you.
  2296.  
  2297. FDATE'S CENTURY-ASSUMPTION ALGORITHM
  2298. ====================================
  2299. If an input date is supplied in a format in which the year is
  2300. specified without a century -- that is, as YY rather than CCYY --
  2301. then Fdate does not automatically use the current century.
  2302. Instead,
  2303.  
  2304.    *  if YY is greater than 20,       then FDATE assumes CC = 19
  2305.    *  if YY is less than or equal 20, then FDATE assumes CC = 20
  2306.  
  2307. Examples:
  2308.          21    becomes  1921
  2309.          ...
  2310.          99    becomes  1999
  2311.          00    becomes  2000
  2312.          01    becomes  2001
  2313.          ...
  2314.          20    becomes  2020
  2315. but then (again)
  2316.          21    becomes  1921
  2317.  
  2318. To put it simply, FDATE makes what would be a reasonable assumption
  2319. about the century for someone operating in the 1990's: it looks back to
  2320. 1921 and forward to 2020.  If both I and FDATE are still alive in the
  2321. year 2000, I'll probably update FDATE's century-assumption algorithm to
  2322. shift it forward several decades.
  2323.  
  2324.  
  2325. FDATE'S IMPLEMENTATION LIMITS
  2326. ====================================
  2327. Internally, numbers in Fdate are stored in Turbo Pascal's LONGINT datatype,
  2328. which means that Fdate can accept numbers up to 9 digits long.
  2329.  
  2330. DISTRIBUTION ISSUES
  2331. ===================
  2332.  
  2333. USE, REGISTRATION, AND DISTRIBUTION OF FDATE
  2334. ============================================
  2335.  
  2336. FDATE is freeware, or what is known as "zero-cost shareware".  FDATE is not
  2337. what is technically called "public domain" software because the author
  2338. retains the copyright.  FDATE can, however, be copied, used, and
  2339. distributed freely as long as FDATE.EXE and its associated doc file
  2340. (FDATE.DOC), along with its demonstration batch files and their doc files
  2341. (FDATEX.BAT, HOLIDAYS.BAT, HOLIFEDS.BAT, HOLIFEDS.DOC, TIC.BAT, ALARM.BAT,
  2342. etc.) are not altered and are distributed together.  
  2343.  
  2344. There is no requirement to register FDATE in any way.
  2345.  
  2346. FDATE can be included in shareware packages as long as both FDATE and
  2347. its related files are included in the shareware package.
  2348.  
  2349. If you have received FDATE as part of some larger shareware package,
  2350. please be aware that you may freely use, copy, and distribute FDATE
  2351. without paying a fee for, or registering, the larger package.
  2352.  
  2353. The author explicitly disavows any claim whatsoever about the
  2354. correctness or functionality of FDATE, its documentation, and its
  2355. demonstration batch files, and disclaims liability for anything and
  2356. everything bad that might happen in connection with, before, during, or
  2357. after using it.  I have tried to make FDATE work right, but everybody
  2358. makes mistakes, so you use FDATE at your own risk.
  2359.  
  2360. I don't know if people will find FDATE useful, and I'd like to find
  2361. out.  If you find FDATE useful and use it on a regular basis, I'd
  2362. appreciate it if you would drop me a short note via US mail or
  2363. CompuServe, telling me about how you are using FDATE.
  2364.  
  2365. If you need other input/output formats, please contact the author.
  2366.  
  2367.  
  2368. TECHNICAL SUPPORT FOR FDATE
  2369. ===============================================
  2370.  
  2371. Send me a message via CompuServe mail; I'll respond.  When sending your
  2372. message, please let me know what version of Fdate you're using.
  2373.  
  2374.  
  2375. WHERE TO FIND THE MOST CURRENT VERSION OF FDATE
  2376. ===============================================
  2377.  
  2378. You will always be able to find the most recent version of FDATE on
  2379. CompuServe.  The filename will be FDATE.ZIP, and it will be available in
  2380. one of the libraries in the CIS:IBMSYS forum (probably library 1, the "DOS
  2381. Utilities" library).  You can find it by using cross-library searching,
  2382. looking for the filename FDATE.ZIP or the keyword FDATE.
  2383.  
  2384.  
  2385. UPLOADING FDATE TO ELECTRONIC BULLETIN BOARDS
  2386. ===============================================
  2387.  
  2388. Feel free to post copies of FDATE.ZIP on any BBS that you wish, but please
  2389. do not upload it to any CompuServe library.  As long as I am the only one
  2390. putting copies of FDATE onto CompuServe, we can keep confusion over
  2391. versions to a minimum.
  2392.  
  2393.  
  2394. DEMONSTRATION BATCH FILES
  2395. =========================
  2396.  
  2397. FDATE ships with a number of demonstration batch files.  These are sample
  2398. applications that illustrate some of the ways that FDATE might be used to
  2399. build applications.  They can be studied for ideas for ways of using FDATE. 
  2400. They can also be used "as is", or copied and customized to build
  2401. applications that meet your own special needs.
  2402.  
  2403.  
  2404. CONTENTS OF THE FDATE.ZIP DISTRIBUTION FILE
  2405. ===========================================
  2406.  
  2407. The current distribution package (FDATE.ZIP) contains the following:
  2408.  
  2409.        FDATE.EXE         [the FDATE program]
  2410.        FDATE.DOC         [this file, documentation for FDATE]
  2411.  
  2412.   [demonstration batch files]
  2413.        FDATEX.BAT
  2414.        HOLIDAYS.BAT
  2415.        HOLIFEDS.BAT and HOLIFEDS.DOC
  2416.        ALARM.BAT and ALARM.DOC
  2417.        FILEDATE.BAT
  2418.        TIC.BAT and TIC.DOC
  2419.  
  2420. FDATE REVISION HISTORY
  2421. ======================
  2422.  
  2423. Letters appended to version numbers indicate modifications to
  2424. the doc files, without any modification to the FDATE.EXE software.
  2425. Asterisks (*) indicate most important changes in the new version.
  2426.  
  2427. Most of the revision history before version 6.7 has been omitted, as not
  2428. being of general interest.  
  2429.  
  2430.  
  2431. 3.0a  Dec 27, 1991
  2432. *     =============== MAJOR BUG FIX ==============================
  2433. *     Fixed bug in TRUEDATE date arithmetic routine that caused
  2434. *     incorrect dates to be returned for the last 2 or 3 days of
  2435. *     some months.
  2436. *     ============================================================
  2437.  
  2438.  
  2439. 6.7a  Apr 05, 1992
  2440. *     Added function "E" (echo)
  2441. *     Added output format: "dd mn3 yy"   EXAMPLE:     05 Sep 92
  2442.       Added JDATE.BAT example batch file, thanks to Aran Spence.
  2443.       Corrected a bug in the routine that obtained command line
  2444.             parameters.  It sometimes caused an improper value to be
  2445.             returned if a quoted parameter did not contain a space.
  2446.  
  2447. 6.8a  Aug 01, 1992
  2448. *     I will no longer be posting the most recent version of FDATE
  2449.       in ZNT:UTILFORUM because ZiffNet's new fees would require me
  2450.       to pay $30/year to do so.  Look for the most recent version
  2451.       of FDATE in CIS:IBMSYS.
  2452.  
  2453. *     Added output format:  ddmn3yy    EXAMPLE:     05Sep92
  2454.  
  2455. *     Added output format:       yy    EXAMPLE:          92
  2456.       This should make it easier for users to "roll their own"
  2457.       date formats.  See the "roll your own" example.
  2458.  
  2459. *     Modified documentation in JDATE.BAT to make it clear that it
  2460.       is working with a BUSINESS julian date format: YYjjj.
  2461.       Thanks for the feedback from  Howard S. Friedman (70720,3022)
  2462.  
  2463.       Updated FDATEX.BAT to test the new formats.
  2464.  
  2465. 6.8b   Aug 02, 1992
  2466.        Added example showing how to get last Friday's date using /Fw
  2467.  
  2468.        Modified JDATE.BAT so it describes its Julian date as a 'business
  2469.        julian' date.
  2470.  
  2471. 6.8c   Aug 07, 1992
  2472.        Revised the discussion of "tt" and "tttt" in output formats to make
  2473.        it more compact.  Again, thanks for the feedback from Howard S.
  2474.        Friedman (70720,3022).
  2475.  
  2476. 7.0a   Nov 14, 1992
  2477. *      Fixed bug in which 10-character Spanish-language month-names were
  2478.        being truncated to 9 characters.
  2479.  
  2480. *      Added #mod function
  2481.  
  2482. *      Major reformatting of documentation to make it more user-friendly
  2483.  
  2484.        Removed DO-ONCE.BAT from distribution ZIP file, as it was already
  2485.        documented in an example in this doc file.
  2486.  
  2487.        Added HOLIFEDS.BAT and HOLIFEDS.DOC to the distribution ZIP file. 
  2488.        Calculates Federal holidays in a given year.
  2489.  
  2490. VERSION 7.3a RELEASED
  2491.      
  2492. 7.0b   Dec 15, 1992
  2493.        Corrected last few lines of HOLIFEDS.DOC, which referred to
  2494.        Dec 24, 1964 as a Friday.  It was a Thursday.
  2495.  
  2496. 7.1a   Apr 15, 1993
  2497.        Added German language parm (/Lgr).  Thanks for the request, and the
  2498.        necessary information, from Patrick Schmucki, via the Active-Net
  2499.        BBS in Rapperswil, Switzerland.
  2500.  
  2501. 7.1b   Apr 20, 1993
  2502.        Added LASTDAY.BAT example.  Thanks to Patrick Boyle for the request
  2503.        for an explanation of how this might be done.
  2504.  
  2505. 7.1c   Apr 28, 1993
  2506.        In an attempt to improve the helpfulness of the documentation,
  2507.        moved the detailed description of functions closer to the beginning
  2508.        of this doc file, and added a one-page OVERVIEW OF FUNCTIONS.
  2509.  
  2510. 7.2a   May 1, 1993
  2511.        Corrected German-language name for month of March from "Mrz" to
  2512.        "März"
  2513.  
  2514. 7.3a   May 25, 1993
  2515.        Added output formats "zd. mn ccyy" and "zd. mn3 ccyy" for the
  2516.        convenience of German-speaking users.  Thanks for the request from
  2517.        Patrick Schmucki.
  2518.  
  2519.        Added output format ZM.
  2520.  
  2521.        To this .DOC file, added: 
  2522.        Examples of how to represent a date in 4 bytes, along with the text
  2523.        of SETXX.BAT, and example of how to get information about the month
  2524.        prior to the current month.  Thanks to Richard Beels for the
  2525.        request for ideas on how to do this sort of thing.
  2526.  
  2527.  
  2528. 7.3b   May 29, 1993
  2529.        To this .DOC file, added: 
  2530.        Example of how to use a batch file (FERGIAN.BAT) to customize Fdate
  2531.        for a different language, using a technique similar to SETXX.BAT. 
  2532.        Thanks to Sebastian Bazley, of the Higher Education National
  2533.        Software Archive at Lancaster University, UK, for suggestions that
  2534.        got me started thinking along these lines.  
  2535.  
  2536. VERSION 7.3b RELEASED
  2537.  
  2538. 7.4a   July 7, 1993
  2539. *      Add "V" (validate) function: /Fv
  2540.  
  2541.        Restructured HELP screen into several screens, because the single
  2542.        HELP screen was getting too crowded.
  2543.  
  2544. 7.5a   July 9, 1993
  2545.        Added error checking for input dates that contain a month
  2546.        specification that is less than 1 or greater than 12
  2547.  
  2548. 7.6a   July 9, 1993
  2549.        Added "m" (month addition/subtraction) function: /Fm
  2550.  
  2551. 7.7a   July 10, 1993
  2552.        Added "#mult" (multiplication) function: /F#mult
  2553.        Added "#div" ( division) function: /F#div
  2554.        Added "#idiv" (integer division) function: /F#idiv
  2555.  
  2556. 7.8a   July 14, 1993
  2557.        Added /T (time) parameter
  2558.  
  2559.        Changed value that /Fv produces for an OK date from "OK" to the
  2560.        null string.  This should make it a little easier to use.
  2561.  
  2562.        Removed the TIMER demo from FDATEX.BAT, since it is now in this DOC
  2563.        file.
  2564.  
  2565. 7.9a   July 15, 1993
  2566.        Minor change to the monthly arithmetic code to improve clarity
  2567.  
  2568.        Added error-trapping routines for numeric input parameters that
  2569.        exceed 9 digits, and for results of multiplication operations that
  2570.        overflow limits of Turbo Pascal's LONGINT datatype
  2571.  
  2572. 8.0a   July 15, 1993
  2573.        Added FORATIME.BAT example, which Walter Ledge (assistant sysop of
  2574.        CompuServe's CRFORUM) and I developed.  A big thanks to Walt for
  2575.        his feedback, which provided the spark I needed to add the /Time
  2576.        parameter and the #idiv function.
  2577.  
  2578.        Added JDATE.BAT to the list of examples in this doc file, and
  2579.        removed it from the files included in the .ZIP distribution file.
  2580.  
  2581. VERSION 8.0a RELEASED
  2582.